Reputation: 29186
I have the following jQuery ajax call setup:
function Testing() {
var result = '';
$.ajax({
url: 'BookingUtils.asmx/GetNonBookableSlots',
dataType: 'text',
error: function(error) {
alert('GetNonBookableSlots Error');
},
success: function(data) {
alert('GetNonBookableSlots');
result = data;
}
});
return result;
}
Here is the web service I'm trying to call:
[WebMethod]
public string GetNonBookableSlots()
{
return "fhsdfuhsiufhsd";
}
When I run the jQuery code, there is no error or success event fired (none of the alerts are called). In fact, nothing happens at all, the javascript code just moves on to return statement at the end.
I put a breakpoint in the web service code and it does get hit, but when I leave that method I end up on the return statement anyway.
Can someone give me some tips on how I should be configuring the ajax call correctly, as I feel that I'm doing this wrong. The webservice just needs to return a string, no XML or JSON involved.
Cheers. Jas.
Upvotes: 0
Views: 1129
Reputation: 16292
Just for debugging try this:
$.post('BookingUtils.asmx/GetNonBookableSlots', function(data) {
console.log(data);
}, 'text);
Use the Firebug or HTML Inspector console to view the output. As well, Firebug or HTML Inspector can give you other clues to what the problem is. You can inspect the returned result to see if there was an HTTP error.
Upvotes: 1