I wanted to invoke a .net webservice which is hosted locally on my machine from jQuery .ajax(). the script is included in the static .html file. the success function is triggered but the response data is NULL.
$.ajax({
type: "GET",
data: '{continent: "' + $('#txtContinent').val() + '"}',
url: "http://localhost:60931/Service1.asmx/GetCountries",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
alert(response);
},
failure: function(msg) {
$('#result').empty().app开发者_StackOverflow社区end(msg);
}
});
When i alert the response its giving me NULL, can anyone tell me where im goin wrong, Thanks in advance.
Its because you might be calling the ajax from a static page which is not in http://localhost:60931/
. You can put the static html in the localhost and try to run it via the same url. Or you can debug your ajax call by adding
error : function(xhr,status,error){
alert(status);
},
精彩评论