I can not connect to a Web service, tried a lot of different options and change parameters, prompt where to dig? This is my first experience of connecting via AJAX, I tried through other clients work.
var xhr = $.ajax({
url: webserUrl,
type: "GET",
data: JSON.stringify({ "Tabn": "1","Vaccurrent": "1","Vacnext": "1" }),
cache: false,
crossDomain: true,
username: "user",
password: "password",
processData: false,
contentType: "application/json",
dataType: "json",
headers: {
"Accept": "application/json; odata=verbose"
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
success: OnSuccess,
error: OnError
});
function OnSuccess(data, status)
{
alert(data);
}
function OnError(xhr, ajaxOptions, thrownError, request, error)
{
alert('xrs.status = ' + xhr.status + '\n' +
'thrown error = ' + thrownError + '\n' +
'xhr.statusText = ' + xhr.statusText + '\n' +
'request = ' + request + '\n' +
'error = ' + error);
console.log('xrs.status = ' + xhr.status + '\n' +
'thrown error = ' + thrownError + '\n' +
'xhr.statusText = ' + xhr.statusText + '\n' +
'request = ' + request + '\n' +
'error = ' + error);
}
});
Error:
xrs.status = 200
thrown error = undefined
xhr.statusText = OK
request = undefined
error = undefined
200response code, the HTTP request is going through correctly. I suspect the server isn't returning a JSON response, so jQuery is getting an error when it tries to parse the response.