JQuesr AJAX processing image problem
I have a page using jQuery flot plugin to draw line chart and works well. Now I want to improve it. When the js draws chart it will appear a processing image then display the chart. The code of drawing is like:
$(function () {
$.plot($("#chart"), [ oneday ]);
});
Div wit开发者_如何学Goh image:
<div id="wait">
<img src='wait.gif'/>
</div>
There is no problem of these. But when I write code like this:
$(function () {
$("#chart").ajaxStart(function(){
$("#wait").css("display","block");
});
$("#chart").ajaxComplete(function(){
$("#wait").css("display","none");
});
$.plot($("#chart"), [ oneday ]);
});
There is no image load. Could someone tell me why?
The problem is that ajaxStart
and ajaxComplete
is only called if ajax request start or complete. jqPlot don't use ajax requests. The jqPlot draws the plots on the client side.
$("#wait").show();
$.plot($("#chart"), [ oneday ]);
$("#wait").hide();
It seems the data isn't being requeste by Ajax. So this should work:
$("#wait").css("display","block");
$.plot($("#chart"), [ oneday ]);
$("#wait").css("display","none");
Hope this helps. Cheers
精彩评论