2

I have a site running on a localhost that uses different KendoUI grids loaded from a kendoPanelBar. It was all working fine until I updated to OSX 10.9 (Mavericks). Now I can load a grid once using a $.post jquery call, but then the second time I try and load the grid I receive a 412 (Precondition Failed). I have to empty the cache before it will let me load the grid again. The strangest part is that this is only happening in Safari 7.0. Firefox 24.0 is working as normal and can load the grids with no errors.

Is this a problem with my web server configuration that may have changed due to the upload or... could this be just localized to a problem with the new Safari or... is there something that I could be missing in my code that Safari is now strictly checking?

Andrew Sinagra
  • 232
  • 1
  • 4
  • 14
  • It would appear this is also an issue in Safari on iOS. It's almost as if Apple thought this was correct behaviour. Does anyone know if it is, or could be, considered appropriate? – Haqa Feb 02 '15 at 10:31

1 Answers1

2

After doing some research I found some information related to cross domain loading that suggested this fix, although since I'm not doing cross domain calls I'm not sure why this actually worked. If someone could explain that would be fantastic.

This is the fix by changing the $.post call to using $.ajax with a GET type and async as false.

Here is the original code:

$.post( "myContent.html" )
    .done(function( data ) {
    $("#main_content").html(data);
});

Here is the updated code:

$.ajax({
    type: "GET",
    url: "myContent.html",
    success: function(data) {
        $("#main_content").html(data);
    },
    async: false
});
Andrew Sinagra
  • 232
  • 1
  • 4
  • 14
  • Unfortunately this isn't always an option. My code uses post because the content I'm requesting needs to be fresh and needs to defeat intermediate caches. Is there no other way? – Haqa Feb 02 '15 at 10:32
  • @Haqa can't you just specify `cache` to be `false` when making the AJAX request? – aug Apr 22 '15 at 18:16
  • If browsers tended to listen to that it might be an option, unfortunately my experience has shown that honoring cache controls in patchy in its support at best. – Haqa Jun 10 '15 at 14:01