我把这个代码:
<script type='text/javascript' src='http://code.jquery.com/jquery-2.1.0.min.js'></script>
<script type="text/javascript">
$(document).ajaxStart(function() {
$("#loading-image").show();
});
$(document).ajaxStop(function() {
$("#loading-image").hide();
});在页面的顶部..。
我有HTML:
<body style="">
<div id="loading-image" style="width:100%; height:100%; background:#ccc; display:none;"></div>但是我没有看到ID在ajax上加载图像.这里有什么问题吗?
发布于 2014-04-10 22:23:58
代码似乎没有什么问题,确保无论何时使用ajax,都会调用这些方法,在元素检查器中放置一个断点。还检查当您手动删除显示:没有从“加载-图像”div,您可以看到它在屏幕上,只是为了确保。
发布于 2014-04-10 22:23:02
从您发布的有限数量来看,您实际上并不是在提出AJAX请求。http://jsfiddle.net/volte/A66C8/
然后尝试在页面加载时进行ajax调用:
$.ajax({
url: "test.html",
context: document.body
});免责声明:我没有测试这个。从http://api.jquery.com/jQuery.ajax/拉出来
此外,请确保将这些方法包装在onload中。大多数人都这样做:
(function() {
//... your code here ...
//... will be run on load...
});https://stackoverflow.com/questions/23000111
复制相似问题