$.ajax({
url : "Handler1.ashx",
type : "GET",
cache : false,
data : {
type : "refresh",
point: [x:1,y:2]
});“类型”可以是"POST“。在"Handler1.ashx“中,我有"HttpContext”对象,所以如何从"HttpContext“对象获得json?
我发现这是误会,我的意思是:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
// How can I get json here?
}发布于 2014-01-28 07:15:25
类似于这个问题。pass jquery json into asp.net。按照链接,它可能会对你有用。
发布于 2014-01-28 07:14:34
使用成功回调获取json数据
下面的代码可能对你有帮助。
$.ajax({
url : "Handler1.ashx",
type : "GET",
cache : false,
data : {
type : "refresh",
point: [x:1,y:2]
},
success: function(res){
//do your code.
//here res is your json which you return from Handler1.ashx
console.log(res);
}
});发布于 2014-01-28 07:14:42
您需要使用success回调来捕获从请求返回的数据,如下所示:
$.ajax({
url : "Handler1.ashx",
type : "GET",
cache : false,
data : {
type : "refresh",
point: [x:1,y:2]
},
success: function(responsedata){
alert(responsedata); // <-- there's your data
}
});https://stackoverflow.com/questions/21398945
复制相似问题