62,046
社区成员
发帖
与我相关
我的任务
分享
// 请求加载 Products 数据
var loadProducts = function () {
var xhr = getXHR();
if (xhr == null) return;
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
alert("xhr.responseText: " + xhr.responseText);
var productJSON = document.getElementById("productJSON");
productJSON.innerText = xhr.responseText;
var products = eval('([' + xhr.responseText + '])');
renderProducts(products);
}
};
xhr.open("GET", '/ProductHandler.ashx?action=modifyPwd', true);
//{"id":"3266","name":"JZ12T.2-Q861A嵌入式墨绿聚晶玻璃脉熄双灶(湖北)","price":"¥604.35"} 怎么样把这一条JSON发送过去并解析接收呢?
xhr.send();
};
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/x-javascript";
//string action = context.Request.Params["action"]; //外部请求
String action = context.Request.Params["action"];
//这里怎么接收前台传过来的JSON,并解析呢?
context.Response.Write(GetJsonProducts());
context.Response.End();
}