У меня особенная проблема с получением целого числа из ответа ajax. Всякий раз, когда я вызываю следующий код, parseInt (data) возвращает NaN, несмотря на то, что данные являются строкой.
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);
}
}
});
}
В firebug typeof (data) - это строка, а data = "89" (или другое число от 1 до 100), но все еще не работает Любые подсказки?