Ishantha Dhanushka
Ishantha Dhanushka

Reputation: 1

XMLHttpRequest returns status code 500

When I try to get data from another web site using Ajax, I get a status code 500 error response. This is my code example:

var requestUrl = "http://www.mywebsite.com:8090/api/service.asmx/method";

var postedDataJson = JSON.stringify({
    para1: 'value 1',
    para2: 'value 1'
});

try {
    $.ajax({
        type : "POST",
        url : requestUrl,
        data : postedDataJson,
        contentType : "application/json; charset=utf-8",
        dataType : "json",
        crossDomain : true,
        success : function(response) {
            console.log("success");
        },
        error : function(jqXhr, exception) {
            console.log("error");
        }
    });
} catch (e) {
    options.error("oops! Something whent wrong.");
}

How can I fix this?

Error image in console

Upvotes: 0

Views: 16009

Answers (1)

theDmi
theDmi

Reputation: 18034

A response with a status code 500 indicates an Internal Server Error. That means that there was an unexpected error on the server side that your request triggered.

If you're the developer of the server software, look at the logs or debug the server application to get to the root of the problem. Your JS code looks ok.

Upvotes: 1

Related Questions