JQuery中使用AJAX的实践


  一、最简单用法
  客户端
  $.post("/code/CarState.ashx?method=GetConnState", function(data) {
//执行回调函数,根据返回的data判断
});
  服务器端
  *使用ashx文件,容易点
  if (context.Request.QueryString["method"] != null && context.Request.QueryString["method"].ToString() != "")
{
method = context.Request.QueryString["method"].ToString();
}
if (method != "")
{
//执行功能
   context.Response.Write(); //关健是这个。返回数据
}
  *搞掂,超简单
  二、客户端那边还是另一种方法
  $.ajax({
type: "POST",
url: '/code/AjaxForUserJson.ashx',
data: "method=GetGpsPosition&TID=" + tid,
dataType: "json",
success: function(result) {
   }
   });
  *记得服务器端的提交类型有没有限制,我试过搞了我一天。。JQuery中使用AJAX的实践 - 猎人 - 佛山人 shit~

评论: 0 | 引用: 0 | 查看次数: 35
发表评论
你没有权限发表留言!