javascriptjqueryajaxhttp-status-code-304

JQuery AJAX call: 304 respose produces an error


I have a script on localhost that sends a GET request to the same domain. It results in 304 response, which apparently JQuery treats as an error.

$(document).ready(function(){
    $.ajax({
        type: 'GET',
        url: 'http://localhost/file.js',
        error: function(e) {
            console.log('error: ' + e.responseText); // I see this message in console
        },
        success: function(e) {
            console.log('success: ' + e.responseText); // I don't see this message in console
        }
    });
});

1) Why do I get a 304 response? 2) How can I modify the code so that the success function gets called? (instead of error function)


Solution

  • My guess is the error stems from you receiving a .js file, jQuery is expecting json