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);
}
}
});
}
ファイアバグでは、typeof(data)は文字列であり、data = "89"(または1から100までの別の数値)ですが、まだ機能していません。手がかりはありますか?