JQuery.ajax and asp.net

JQuery.ajax and asp.net

Hey guys,

I'm fairly new to jquery, currently using it for an assignment and I'm asking if maybe anyone came across a solution to the following problem.

I am experiencing a delay when calling an asp.net webserivce that is displaying the output on the web page as "undefined".

The job of the web service is to call a method to get a particular value from MySQL. The value that I want is being returned because when I use alert(response.d), the value shows up. but when I do:

  1. $.ajax({
  2.         type: "POST",
  3.         url: "tableID.asmx/getLastID",
  4.         contentType: "application/json; charset=utf-8",
  5.         dataType: "json",
  6.         success: function (response) {
  7.             return response.d;
  8.         },
  9.         Error: function (msg) { alert(msg); }
  10.     });
With the above, I'm getting undefined and this is all because of this delay. When I use firebug to debug the code and I take my time, the value that I want comes up.

If you guys knows about a solution, you'd do me a great big favour! thanks :D