PDA

View Full Version : Duplicate Ajax request in Safari



csky
28 Aug 2013, 11:50 AM
When I run in Safari (Mac or PC), I see all of my Ajax requests are being received twice by the backend web server. I don't see this problem with Chrome or Firefox.

Here are some examples fomr the access logs from the Lighttpd server. I can see the __dc query is the same.



192.168.1.1 192.168.1.2 - [28/Aug/2013:12:37:47 +0000] "GET /api/foo?_dc=1377718676427 HTTP/1.1" 200 66 "http://192.168.1.2/www/safari-double.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.59.8 (KHTML, like Gecko) Version/5.1.9 Safari/534.59.8"
192.168.1.1 192.168.1.2 - [28/Aug/2013:12:37:47 +0000] "GET /api/foo?_dc=1377718676427 HTTP/1.1" 200 66 "http://192.168.1.2/www/safari-double.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.59.8 (KHTML, like Gecko) Version/5.1.9 Safari/534.59.8"

192.168.1.1 192.168.1.2 - [28/Aug/2013:12:37:51 +0000] "GET /api/foo?_dc=1377718680428 HTTP/1.1" 200 67 "http://192.168.1.2/www/safari-double.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.59.8 (KHTML, like Gecko) Version/5.1.9 Safari/534.59.8"
192.168.1.1 192.168.1.2 - [28/Aug/2013:12:37:51 +0000] "GET /api/foo?_dc=1377718680428 HTTP/1.1" 200 67 "http://192.168.1.2/www/safari-double.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.59.8 (KHTML, like Gecko) Version/5.1.9 Safari/534.59.8"


The requests don't show as duplicates in the Safari Developer Tools Network tab but I can see the requests in Wireshark. Strange.

My guess is this might not be an ExtJS issue, but maybe some one here has come across this issue before. Anyone have any thoughts?

scottmartin
4 Sep 2013, 8:30 AM
Do you see this is you just create a simply button app that triggers an ajax request .. or just in your app?

Scott.

csky
4 Sep 2013, 11:23 AM
It wasn't just the app. I made a number of sample programs in ExtJS, jQuery, and with native XHR that all showed the problem.

I found a similar question on Stackoverflow and it suggested adding "Connection: close" to the the response.

http://stackoverflow.com/questions/5956501/safari-double-submitting-ajax-calls

I'm not sure why this happens only with Safari. It seems like everyone would encounter this at some point. Very strange.

I suppose I can close this since it really isn't an ExtJS issue.