Why does my $ .ajax request always fail?

This is how i use $.ajax

var link = "http://www.myapp.net/..."

$.ajax({
    url: link,
    cache: false,
    async: false,
    success: function(html){

    },
    error: function(){

    }
});

The query result is either a blank page or a page with just a number. Thus, the error callback should never be run until the request is interrupted.

But I always get the following error

alert(jqXHR + "-" + textStatus + "-" + errorThrown);

enter image description here

Here is some info about the error code in the picture

I am running my project on localhost. The link in the ajax code points to another project on the Internet.

Any ideas?

+3
source share
1 answer

The error callback is executed if the ajax call cannot be completed, i.e. if the URL is in another domain (or if you use it from a local file), if the request timeouts or if the server responds with an error code.

, ( )

. - Ajax, jQuery ( Yahoo! jQuery Ajax -)

+5

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


All Articles