jquery的ajaxSetup()函式用法:設定全域性的ajax預設選項
阿新 • • 發佈:2019-02-04
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
<script src="jquery.js"></script>
<script>
jQuery(document).ready(function(e){
$.ajaxSetup({url:"serialize.php",success:function(result)
{
$("div").html(result);
}
});
$("#btn").click(function()
{
$.ajax({data:{firstname:"liu",secondname:"ming"},type:"POST"});
});
/*$("#btn").click(
function()
{
$("ul").load("test.html div p span");
}
)*/
});
</script>
</head>
<body>
<ul></ul>
<div>this is hint</div>
<input type="button" id="btn" value="check it">
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
<script src="jquery.js"></script>
<script>
jQuery(document).ready(function(e){
$.ajaxSetup({url:"serialize.php",success:function(result)
{
$("div").html(result);
}
});
$("#btn").click(function()
{
$.ajax({data:{firstname:"liu",secondname:"ming"},type:"POST"});
});
/*$("#btn").click(
function()
{
$("ul").load("test.html div p span");
}
)*/
});
</script>
</head>
<body>
<ul></ul>
<div>this is hint</div>
<input type="button" id="btn" value="check it">
</body>
</html>