Jquery Ajax示例---load,get,post方法
jQuery load() 方法
$(selector).load(URL,data,callback);
必需的 URL 参数规定您希望加载的 URL。
可选的 data 参数规定与请求一同发送的查询字符串键/值对集合。
可选的 callback 参数是 load() 方法完成后所执行的函数名称
$("button").click(function(){
$("#div1").load("demo_test.txt",function(responseTxt,statusTxt,xhr){
if(statusTxt=="success")
alert("外部内容加载成功!");
if(statusTxt=="error")
alert("Error: "+xhr.status+": "+xhr.statusText);
});
});
Jquery get()方法
$.get(URL,callback);
$.get("do_post.php?user=zyz",function(data,status) {
$("div").html("data:"+data+"<br>status:"+status);
});
Jquery post()方法
$.post(URL,data,callback);
$.post("do_post.php",{"user":"julia"},function(data,status){
$("div").html(data);
});
浙公网安备 33010602011771号