I have the following code:
$("button").click(function() {
$.ajax({
url: 'http://***.com:3000/login',
data: {
format: 'json',
username: $('#username').val(),
password: $('#password').val()
},
error: function() {
console.log("error");
alert('FAIL');
},
dataType: 'jsonp',
success: function(data) {
alert('OK');
console.log("success");
},
type: 'GET'
});
})
The situation is that once I send a valid username and password and I see that the server code reaches the line:
res.status(200).send("OK");
the moment the response returns to the client, the code enters the 'error' case.
The console of the browser shows:
Uncaught ReferenceError: OK is not defined
at <anonymous>:1:1 at p (jquery.min.js:2) at Function.globalEval (jquery.min.js:2) at text script (jquery.min.js:4) at Nb (jquery.min.js:4) at A (jquery.min.js:4) at XMLHttpRequest.<anonymous> (jquery.min.js:4)
It's really odd because it doesn't point to any place in my code.
The network tab says:
It seems like instead of 200 HTTP code, I have 304.
Do you know why and how to fix it?