(1) .load()方法:$(selector).load(URL,data,callback);
如:
$("#div1").load("sample.txt",function(responseTxt,statusTxt,xhr){ if(statusTxt=="success"){ alert("外部内容加载成功!"); }else if(statusTxt=="error"){ alert("Error:"+xhr.status+": "+xhr.statusText+""); } });
(2) .get()方法: $.get(URL,callback);
$("#btn1").click(function(){ $.get("demo_test.asp",function(data,status){ alert("Data: "+data+"\nStatus: "+status+""); }); });
(3) .post()方法: $.post(URL,data,callback);
$.post("demo_test_post.asp",{ name:"Norton", city:"ShenZhen" },function(data,status){ alert("Data: "+data+"\nStatus: "+status+""); });