索引.html:
<html>
<head>
<script type="text/javascript" src = "jquery-1.10.1.js"></script>
<script type="text/javascript" language = "javascript">
console.log("mm");
function swapContent(cv) {
console.log("mmn");
$("#myDiv").html('<img src="loader.gif" width="44" height="10" alt="loader.gif">').show();
var url= "myphpscript.php";
$.post(url, { contentVar: cv }, function(data) {
$("#myDiv").html(data).show();
});
console.log("mmn");
}
</script>
</head>
<body>
<a href = "#" onClick = "return false" onmousedown = "javascript:swapContent('Con1');"> Content1 </a> •
<a href = "#" onClick = "return false" onmousedown = "javascript:swapContent('Con2');"> Content2 </a> •
<a href = "#" onClick = "return false" onmousedown = "javascript:swapContent('Con3');"> Content3 </a> •
<div id = "myDiv"> My Default Content 1</div>
</body>
</html>
gif 已保存在与索引相同的文件夹中。div 正在动态更改,但 gif 似乎已加载。我需要延迟什么的吗?怎么做?还是代码有其他问题?