- $.get("search.do",{id:1},rend);
- function rend(xml){
- alert(xml);
- } (1)
- $.post("search.do",{id:1},rend);
- function rend(xml){
- alert(xml);
- } (2)
get和post用法一样。第一个参数是异步请求的url,第二个为参数,第三个回调方法。
例子:
$.get("/platform/contact/resetStatus.do?actionType=test",{},rend);
function rend(xml){
$(xml).find("callcenter_response").each(function(){
var id=$(this).children("policy_id");
var policy_id=$(this).children("policy_id").text();
var policy_code=$(this).children("policy_code").text();
alert(policy_id);
});
}
$(document).ready(function() {
$("#msg").ajaxStart(function(){ //一定要写在ready内
$("#msg").html("正在加载。。。。");
});
$("#msg").ajaxSuccess(function(){
$("#msg").html("加载完成!");
});
$("#hello").click(function(){
$("#msg").fadeIn("fast"); //渐入的效果
$("#msg").fadeOut("slow"); //淡出的效果
});
});
<div id="msg">提示信息</div>
<input type="button" id="hello" class="button" value="测试"/>