JQuery Ajax的相关函数:
1、$(selector).load(url,data,callback):返回远程访问后的内容
说明:
url:远程链接地址
data:需要发送传递的参数
callback:完成后执行的函数
2、$.ajax(options):把远程数据加载到 XMLHttpRequest 对象中
说明:options:完整 AJAX 请求的所有键/值对选项
实例:
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#b01").click(function(){
htmlobj=$.ajax({url:"/jquery/test1.txt",async:false});
$("#myDiv").html(htmlobj.responseText);
});
});
</script>
</head>
<body>
<div id="myDiv"><h2>通过 AJAX 改变文本</h2></div>
<button id="b01" type="button">改变内容</button>
</body>
</html>
3、$.get(url,data,callback,type):使用 HTTP GET 来加载远程数据
说明:type:被返回的数据的类型 (html,xml,json,jasonp,script,text)
4、$.post(url,data,callback,type):使用 HTTP POST 来加载远程数据
5、$.getJSON(url,data,callback):使用 HTTP GET 来加载远程 JSON 数据
其他相关ajax函数:http://www.w3school.com.cn/jquery/jquery_ref_ajax.asp