胡志敏

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

//这里是获取url上面的搜索的关键字

js代码部分

var url = decodeURI(window.location.search);
var searchs = url.substr(url.lastIndexOf("all=") + 4);

$("#adv1").append(" ");
if (searchs != null && searchs != "") {
$.ajax({
async: true,//为了不影响页面打开速度,采用异步加载。
url: "Url/Handler1.ashx",
type: "get",
dataType: "jsonp",
data: { searchs: searchs },
success: function (msg) {
var a = eval(msg);
$("#adv1").empty();
$("#adv1").append(msg[0].aa);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Error" + textStatus + errorThrown);
}
});
}

/ashx 部分

context.Response.ContentType = "text/plain";
string callbackfunname = context.Request.QueryString["callback"];

 

//获取数据,得到json 数组 json

string sbb = json.ToString();

//返回数组
context.Response.Write(callbackfunname + "(" + sbb + ")");
context.Response.End();

是不是很简单!

posted on 2012-11-10 12:07  懂了遗憾  阅读(555)  评论(0编辑  收藏  举报