0

I am wanting to receive a more detailed response on a domain through ajax.

Currently I have the code:

$.ajax({
    url: domain,
    type: "POST",
    data: {
        //Set an empty response to see the error
        xml: "<response></response>"   
    },
    datatype: 'application/json',
    complete: function(xhr, textStatus) {
        console.log(xhr.status);
    } 
});

For example if I have a URL that does 'not exist' I get the error report:

0

And if I have a URL that is behind a redirect I get the error report:

0

But these are completely different issues.

And I am sure there are many other examples.

I am doing this to test whether DNS settings have been put in place. As with the second case the DNS settings could be working but there is just a redirect on that domain?

maxisme
  • 3,974
  • 9
  • 47
  • 97

2 Answers2

0

Did you already try the error callback function from Ajax?

Refer to http://api.jquery.com/jquery.ajax/ for this method.

Zinnhead
  • 45
  • 4
0

I can try to change it to

$.ajax({
    url: domain,
    type: "POST",
    data: {
        //Set an empty response to see the error
        xml: "<response></response>"   
    },
    datatype: 'application/json'
})
.done(function (data) {
    //  process response data here...
})
.fail(function (xhr, error, thrownError) {
    //  process error here...
    console.log(xhr, error, thrownError);
});

it perfectly works for me and provide all detailed information that I need

Mr. Pumpkin
  • 6,212
  • 6
  • 44
  • 60