I did an AJAX call which just returns a number:
var lastID = 0;
var loading = true;
// Get latest message ID
$.ajax({
url: "libs/getLatestMessageID.ajax.php",
dataType: "text",
type: "GET",
success: function(data) {
lastID = data;
console.log("Received latest message ID: " + typeof(data) + " \"" + data + "\" " + parseInt(data, 10));
},
});
What I receive from the server is a string, e.g. "21", which now needs to be converted to a number so JS can calculate with it. In Firefox, it works fine, the output of the console.log() row is:
Received latest message ID: string "21" 21
But Google Chrome makes parseInt() return this:
Received latest message ID: string "21" NaN
What goes wrong here?