To simplify my situation; I have 3 PHP pages. Two of them adds and removes rows from a database, respectively. The third fetches all of the rows, encodes them as JSON and prints the result.
I have timed the execution of all the pages, which ranges from 0.001 to 0.004 seconds. Here are the timings of the Ajax calls however:
Fetch entire table as JSON: 8-12ms
Add row: 990-1010ms
Remove row: 990-1010ms
The response time of the add and remove times are causing unnecessary sluggishness in my application, considering the PHP execution times are mere fractions of seconds, and their output is simply "1" for success and "0" for failure (Compared to the fetch call, which prints out up to 100 rows (~10 columns) of data as JSON)
All my Ajax return timings are measured in Firebug. All Ajax calls are made through jQuery ($.ajax()
).
I'm guessing this has something to do with Firefox not considering a GET request answered unless it has received a particular amount of bytes or characters, and the 1 second response time being a timeout of some sort.
Any wisdom to share on the issue?
I've timed the AJAX loading times in Chrome and Opera as well (Averages):
Opera:
* All AJAX calls ~15 ms
Chrome:
* Remove row and fetch rows: ~25ms
* Add row: ~350ms
My application is snappy and responsive in Opera, but sluggish to a varying degree in all other browsers. Exactly why is still unclear to me.
I've timed IE 9 as well, which performs practically identically to Opera. My application now operates swiftly in two browsers.
Apparently some browsers experience mysterious side effects from using localhost
rather than 127.0.0.1
in the URL. The added full second of delay was one of them. Using 127.0.0.1
solved the issue for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With