duanshan1511
2013-07-13 13:09
浏览 206
已采纳

jQuery $ .get请求无效

I have a file upload form, the following javascript fires as soon as the form is submitted:

$("#uploader").submit(function() {
    $("#indicator").show();
    alert("Submitted");
    var refresh = setInterval(function() {
        $.get("progress.php?getprogress&randval=" + Math.random(), function(data) {
            alert("Got " + data);
            $("#indicator .bar div").width(data + "%");
            if (data == 100) {
                clearTimeout(refresh);
                $("#indicator").addClass("done");
            }
        });
    }, 250);
});

I added some alerts to debug, I get the alert("Submitted"), but not the one alerting the data. The php is fine, opening it in a separate window gives the correct values, but the javascript does not get it. Another weird thing is that if I stop the page load, the alert() with the value fires and code is processed.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题