views:

1153

answers:

1

I've got an XHR request that's succeeding in FF3.5 but apparently failing when done in Safari 4. I'm looking at the xhr requests in the debugger in Safari, and Firebug in Firefox.

So on the backend service that's being hit, if the username and password are missing from the POST parameter then the service gives a 500 error. If the parameters are there(even if incorrect), it gives 200 or 40x depending on the error.

Anyway, so with the same code its working for the non-Safari browsers. Safari gets the 500 error like the user/pass aren't being passed through.

As I'm examining the requests in the debugger, it doesn't look like it shows POST data in the logs.

Is there an option I need to enable, or just how do you debug these requests in Safari 4?

+2  A: 

If you are referring to the Safari "Web Inspector": it indeed does not show the POST data when sent using Ajax. I'd use a packet sniffer like Wireshark (but just because I also use it for other things), or a debugging proxy.

Some things to check with your POST: are you invoking setRequestHeader to set the required HTTP headers, like Connection, Content-Type and Content-Length? And as your code works with Firefox, I assume you are actually setting the POST content using send? Post your code in JS Bin please!

(Just for the archives: apart from enabling the debug menu through defaults.write, Safari 4 also has a Develop menu that you can simply enable through the advanced preferences. Choose "Show Web Inspector ⌥⌘I" and you should be able to see the requests and responses on the Resources tab. Ensure to select "Sort by Start Time". If the XHR is sent through GET, one obviously has to look at the request URL itself, which is shown fine. However, for POST, the request headers are shown, but the POST data is sadly missing. I've never used the debug menu though.)

Arjan