I've created a webservice to the which the calls is from a jquery ajax function. But even when async set to true it is not working asynchronously..
My ASP.NET webservice code
<System.Web.Services.WebMethod()> _
Public Shared Function sampleService(ByVal ttid As String) As String
Threading.Thread.Sleep(5 * 1000)
Return "Hello World"
End Function
JQuery Call script
<script language="javascript">
$(function() {
var tempParam = {
ttid: 100
};
var param = $.toJSON(tempParam);
$.ajax({
type: "POST",
url: "testservice.aspx/sampleService",
data: param,
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
error: function() {
alert("Error");
},
success: function(msg) {
alert("Success")
alert(msg.d)
}
});
}); </script>
Here I set it as async = true. Even then I'm getting the success message after 5 seconds. That means not asynchronous. What I believe is if async = true it will not wait for the message from the webserivice. That is actually my requirement.