JQuery AJAX not redirecting?

I have a simple PHP page (for testing) that just calls , which is on the same server, in the same directory as another file with the following jQuery Javascript:header("Location: http://www.example.com");exit;

$(document).ready(function() {
    jQuery.ajax({
        type : 'GET',
        url : 'bounce.php',
        error : function(xhr, status, error) {
            console.log("ERROR: ", xhr, xhr.status, xhr.getAllResponseHeaders());
        },
        complete : function(xhr, status) {
            // Get headers of the response
            console.log("COMPLETE: ", xhr, xhr.status, xhr.getAllResponseHeaders());
        }
    });
});

I expected (from several other StackOverflow answers) for xhr.statusto return "302", but instead the AJAX call raises the error event (and then the "full" event) and xhr.statusreturns 0(zero) and .getAllResponseHeaders()returns null(as in the case of an error, so and in full functions).

Firebug "302 Moved Temporarily" . , , 302 ?. - , script script ? jQuery Javascript?

+3
3

, . , , XMLHttpRequest . example.com , , , example.com.

+1

XMLHttpRequest 301 302 ; , URL- , . , URL, , , URL.

301 302. , , , .

+3

, Amir v64, , :

  • Firebug , XMLHttpRequest,
  • XMLHttpRequest ( "http://www.example.com" )
  • XMLHttpRequest , .

The end result: to implement OpenID, it is not possible to use only Javascript, it must extract from scripts on the same server as the one that handles the search for deleted files.

And the error response on XMLHttpRequest does not give very informative errors when it encounters this security wall.

0
source

Source: https://habr.com/ru/post/1785295/


All Articles