【发布时间】:2017-01-07 05:33:50
【问题描述】:
我正在努力向here学习,
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
jQuery.support.cors = true;
$.ajax({
crossDomain: true,
async : true,
type: "POST",
url: "http://san.gotdns.ch:8025/json",
success: function(result){
$("#div1").html(result);
},
jsonpCallback: 'callbackFnc',
failure: function () { },
complete: function (data) {
$("#div2").html("Success : ");
if (data.readyState == '4' && data.status == '200') {
//document.write("Success : ");
//document.write(data);
}
else {
document.writeln("Failed");
}
}
// -----
}
);
});
});
</script>
</head>
<body>
<div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>
<button>Get External Content</button>
<div id="div2"><h2>Complete</h2></div>
</body>
</html>
如何将其设置为在页面加载时自动运行。并在 5 秒后运行它。 this 之类的东西,但我想获取 URL 而不是显示/隐藏 div!
【问题讨论】:
标签: javascript jquery ajax