方法1:
$(document).ready(function () {
$.ajaxSetup({ cache: false });
$("#btn1").click(function () {
$.post("Handler1.ashx", { name: "test", address: "中国北京" },
function (data) { alert("Data Loaded: " + data); });
});
});
方法2:比较全面
$(document).ready(function () {
$.ajax({
type: "POST",
url: "Handler1.ashx",
data: "name=test" + "&address=中国北京",
beforeSend: function () {
$("#Div1").html("正在查询....");
},
success: function (msg) {
$("#myDiv").html("<h1>" + msg + "</h1>");
},
complete: function () {
$("#Div2").html("查询已完成....");
$("#Div1").html("");
},
error: function () {
$("#Div3").html("处理有误");
}
});
});
});