We are trying to pass credentials to our site via jquery ajax (not using php [yeah I know this is unsafe]).
It seems Safari is having trouble with the username/password attributes of the ajax method. (jquery ajax) We are using jquery 1.5.1.
Here is example code:
$.ajax({
url: "/some/url",
type: 'GET',
cache: true,
dataType: 'json',
processData: false,
data: 'get=login',
timeout: 7000,
username: "user",
password: "pass",
success: function (data, textStatus, response) {
Log("success");
},
error: function (data, textStatus, response) {
Log("fail");
}
});
This works fine in Firefox, Chrome, and IE7/8, but Safari won’t even send the ajax to the server (did a trace with wireshark and nothing is going down the pipe). Strangely enough, the error function gets called.
If I comment out username and password, the ajax is sent.
I was able to fix this problem by using
beforeSendand creating a request header. Apparently if this isn’t included, Safari chokes and doesn’t send anything. Here’s the code: