我想要一個從服務器獲取數據的進度條,所以我創建了兩個servlet,第一個(process
)啓動該進程,並在結束時返回結果;第二個(GetEvent
)每500毫秒從會話中獲取進度信息。未執行JQuery回調?
所有這些都正常工作,並且進度信息顯示正確,但 處理Servlet的回調從不執行。
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script>
$(document).ready(function() {
process();
$("#progressbar").progressbar({ value: 0 });
$("#progressStatus").html("");
getEvent();
});
function process()
{
$.getJSON("process", function(result){
//never executed
alert("Result: ");
});
}
function getEvent()
{
$.getJSON("GetProgressEvent", function(data) {
$.each(data.ProgressEvents, function(){
$("#progressbar").progressbar({ value: this.progress });
$("#progressStatus").html(this.status);
});
});
setTimeout(getEvent, 500);
}
</script>
</head>
<body style="font-size:62.5%;">
<div id="progressbar"></div>
<div id ="progressStatus"></div>
</body>
</html>
我剛開始使用JQuery,我不知道這段代碼有什麼問題。
你確定GetProgressEvent調用實際上返回?您是否使用Web瀏覽器檢查器(例如Chrome或FireFox中的Net面板)檢查了HTTP通信? –