I need to display an alert based on occurrence of string in a JSON response. Here is my code:
$.ajax({
method: 'POST',
url: dataString2,
data: dataString,
headers: {
"Authorization": "Basic " + btoa('' + Username + '' + ":" + '' + Password + '')
},
success: function(jqXHR) {
if (jqXHR.responseJSON('ok')) {
alert('First Real Server Configured');
}
},
statusCode: {
406 : function() {
alert('There is an unexpected string in your data.\nFix the error and try again.');
},
401 : function() {
alert('Wrong username or password.');
}
},
});
});
Here is the JSON response:
{
"status":"ok"
}
HTTP response code is "200 OK", and the server is responding with Content-Type:application/json
When using the above code, I get: Uncaught TypeError: undefined is not a function
Any idea?