3

The problem only occurs on Safari for Mac. I'm loading clean json data files, with the following:

$.ajax({
        url : url,
        type : 'POST',
        dataType : 'json',
        contentType : 'application/json; charset=utf-8',
        crossdomain: true,
        context : contextObj.context,
        success : function(data) {
            // Irrelevant

            callBackHandler.call(contextObj.context, event);
        },
        error: function (xhr, ajaxOptions, thrownError) {
            console.log(xhr.status);
                console.log(thrownError); 
        }
    });

My CORS enabled server has the following:

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header set Access-Control-Allow-Headers "Content-Type, If-Modified-Since, If-None-Match, *"
Header set Access-Control-Max-Age "3600"

I captured the request headers and the only difference I see is in the following. To be clear, the following is included in the failed request, while the next refresh does NOT include the following. Hence the addition of items to the Access-Control-Allow-Headers:

If-Modified-Since: Fri, 08 Mar 2013 15:57:07 GMT
If-None-Match: "6801d-c550-4d76be008fac0"

Is this a server configuration problem, jQuery usage, or something else? It's odd to me that Safari consistently changes the headers on every other refresh.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
  • Michael, question is clearly about cross-domain AJAX but you also mention page refresh. Could you elaborate on the scenario please. – Beetroot-Beetroot Mar 11 '13 at 18:58
  • When a web page is loaded $.ajax() is used to retrieve a *.json file from another web server. The object is used to render an animation. The problem manifested when attempting to replay the animation by manually refreshing the page via the browser. It's apparent that Safari on Mac behaves differently than other browsers, but I don't know why it's sending additional headers on every other request or how to compensate for it either in the client or at the server. –  Mar 11 '13 at 23:49
  • You put wildcard in the access-control-allow-headers header. It's not correct. The correct way is specified in: http://stackoverflow.com/questions/13146892/cors-access-control-allow-headers-wildcard-being-ignored – Chuan Ma Mar 12 '13 at 05:35
  • I just tried removing the * from the server settings, restarted web service - failed, restarted system - still failed. The differences in Safari's successful request and failed request seem to be a clue; however, do I have the right settings... even for the failed request? –  Mar 12 '13 at 05:53

0 Answers0