Call PHP rest webservice from ajax MVC asp.net?

294 views Asked by At

i am trying to call php rest webservice from MVC ajax but after calling it it is not going to call success i dont what i am missing here.

webservice required 2 paramaters my code

 $.ajax({
    type: "POST",
    url: "https://test.com/custom/",
    dataType: "json",
    contentType: "application/json",
    data: { "ReleaseVersion": "XXX", "ReleaseType":"XXX" },
    success: function (data) {
        alert("webservice called successfully");
    }
})

it tried using json.stringfy while passing parameters but it wont work. is anyone how to solve this. Environment: Visual Studio 2013 and MVC 4.0.

1

There are 1 answers

0
user26464 On

set datatype in ajax call that is jsonp for calling cross domain webservice.

In php webservice code you have to add header before passing json.

as header content type=application/json, then and then only you will get json from php webservice in your ajax call.