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

+1


a source to share


4 answers


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.



+6


a source


If you are using firebug firefox, in the console tab it will show you how long the request / response will take, you can also (if you have access) log how long the back process has been running, which will hopefully give you a reasonable idea where is the lag.



+5


a source


If there is some terrible code in the background, your speed problems are most likely caused by network problems. JavaScript / Ajax doesn't hold you back, or at least it doesn't seem intuitive.

+1


a source


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

0


a source







All Articles