JQuery and Ajax
I am working on adding async form in jquery dialog. I am using .ajax (). Everything works correctly, but the submission takes longer than we would like. I'm new to jquery and not sure how to debug / optimize this. How to determine if the lag is in front or backend?
Thanks,
Natasha
While without some code there is no way to know about your specific situation, there won't be any delays with Javascript unless you do something that will obviously take up a lot of browser resources (sorting large tables, adding a lot of HTML, etc.) ... If all you are doing is capturing the data, serializing it and sending it using AJAX to the server, and it takes a long time to respond, then the problem is with the server side code. You can check this with a tool like Firebug , which shows you when the request started and how long it took for the server to respond once it did.
a source to share
To determine where the slowdown is occurring, you can use a Date object to get the number of milliseconds currently (right after clicking the Submit button), then add a funciton beforeSend
to jQuery.ajax({beforeSend: function() { ... });
by adding the time from the start of the tag somewhere on the page. Then you can use complete
to determine how long to start.
JQuery.ajax options: http://docs.jquery.com/Ajax/jQuery.ajax#options
JS Date Object: http://www.w3schools.com/jsref/jsref_obj_date.asp
a source to share