views:

192

answers:

4
+1  Q: 

JQuery Ajax

I'm using JQuery to make AJAX callbacks to asp.net page methods. All works well. However, when I click a hyperlink to go to a new page while a long running callback is in progress, target page doesn't respond normally. Seems like it's waiting for a callback to finish because target page responds in same amount of time it takes for a callback to complete. If there are no callback in progress, new page responds instantly. Stepping through code in debugger, I see error handler is called when hyperlink is clicked which aborts callback and sets readyState to 4 and status to 0.

So, if a long running callback is correctly aborted when hyperlink is clicked, why is it taking so long to get to new page?

Thanks. Charlie

A: 

An error in the auto generated JavaScript. Can you enable script debugging and see if the error occurs before you leave the page?

A: 

Have you ever successfully executed your Ajax on your particular system? If you haven't, it's probably a browser compatibility issue - I would try JQuery, Dojo, or Scriptaculous because they work smoothly with common browsers. Raw ajax can be quite frustrating and difficult to debug.

And like Yuriy said, some code would help. Good luck!

happythenewsad
A: 

Firebug for Firefox was born to figure out this type of problem.

Enable Firebug, keep the console tab open. A new line will appear for each web service call in the console. Cool think is you can inspect what is being sent and received.

Chris Brandsma
A: 

The 'success' parameter (along with 'error', 'dataFilter', etc...) of the $.ajax function is actually a callback function that is executed when you receive the response from the server.

So the script will continue running after you make your AJAX request and then return to that callback function when you receive the response.

Example

$.ajax({
  url: 'ajax/test.html',
  success: function(data) {
     //Runs after response is received
     //Put stuff that depends on the response from the server here
  }
});
//Next statement runs immediately after request
//Put stuff here that can run right away
Dave