什么是jQuery中的jQuery.ajaxSetup()方法?
jQuery.ajaxSetup()方法为将来的AJAX请求设置全局设置。这是此方法使用的所有参数的说明-
假设我们在result.html文件中包含以下HTML内容,
<h1>这是结果... </ h1>
以下是显示此方法用法的示例。在这里,我们使用成功处理程序来填充返回的HTML:
<html>
<head>
<title>The jQuery Example</title>
<script src = "https://cdn.staticfile.org/jquery/2.1.3/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#driver").click(function(event){
//进行全局设置。
$.ajaxSetup({
url: "result.html"
});
$.ajax( {
success:function(data) {
$('#stage').html(data);
}
});
});
});
</script>
</head>
<body>
<p>Click on the button to load result.html file:</p>
<div id = "stage" style = "background-color:#cc0;">
STAGE
</div>
<input type = "button" id = "driver" value = "Load Data" />
</body>
</html>热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志