Hey,
I am having a peculiar problem with getting an integer from an ajax response. Whenever I call the following code, parseInt(data) returns NaN despite data being a string.
function poll() {
$.ajax({
type: "GET",
dataType: "html",
url: 'images/normal/' + userId + '/' + saveCode + 'progress.txt',
error: function() {poll();},
success: function(data) {
// Change the text
$('#loading_text').html(data + '% complete');
// Change the loading bar
max = 357;
current_percent = parseInt(data); // returns NaN
$('loading_bar').width(Math.round(max * (current_percent / 100)));
// Call the poll again in 2 seconds
if (loaded != true)
{
setTimeout( poll, 2000);
}
}
});
}
In firebug, typeof(data) is string and data = "89" (or another number from 1-100) yet it still isn't working. Any clues?