如何捕捉在ashx的文件中的数组数据?数组、文件、数据、ashx

由网友(Hickey.(吻痕))分享简介:我的AJAX code $。阿贾克斯({网址:AnswerHandler.ashx键入:GET,数据:({QID:keyArray,名称:SNAME}),异步:假的,成功:函数(MSG){如果(MSG ==成功){警报(答案保存成功!);}其他{警报(答案保存失败!);}}});现在在AnswerHandler.ash...

我的AJAX code

  $。阿贾克斯({
                        网址:AnswerHandler.ashx
                        键入:GET,
                        数据:({QID:keyArray,名称:SNAME}),
                        异步:假的,
                        成功:函数(MSG){
                            如果(MSG ==成功){
                                警报(答案保存成功!);
                            }
                            其他{
                                警报(答案保存失败!);
                            }
                        }
                    });
 

现在在AnswerHandler.ashx文件我用下面的行获得名数据

 字符串名称= context.Request.QueryString [名称];
 

但我怎样才能得到QID这是一个数组?

解决方案

  $。阿贾克斯({
    网址:AnswerHandler.ashx QID125487,
        键入:GET,
        数据:({QID:keyArray,名称:SNAME}),
        异步:假的,
        成功:函数(MSG){
        如果(MSG ==成功){
            警报(答案保存成功!);
        }
        其他 {
            警报(答案保存失败!);
        }
    }
});
 
超级硬盘数据恢复软件 超级硬盘数据恢复软件下载 v5.0 官方版

而在ashx的文件,你可以得到的值

  INT attId = Convert.ToInt32(context.Request.QueryString [QID]);
 

在这种方式,您可以发送查询字符串多个值,并使用您要发送的查询字符串的名称获取值。

My AJAX Code

$.ajax({
                        url: "AnswerHandler.ashx",
                        type: "GET",
                        data: ({ qid: keyArray , name: sName}),
                        async: false,
                        success: function(msg) {
                            if (msg == "success") {
                                alert("answer saved successfully!");
                            }
                            else{
                                alert("answer saving failed!");
                            }
                        }
                    });

Now in AnswerHandler.ashx file I get name data by following line

string name = context.Request.QueryString["name"];

But how can i get qid which is an array?

解决方案

$.ajax({
    url: "AnswerHandler.ashx?qid"+125487,
        type: "GET",
        data: ({ qid: keyArray , name: sName}),
        async: false,
        success: function(msg) {
        if (msg == "success") {
            alert("answer saved successfully!");
        }
        else {
            alert("answer saving failed!");
        }
    }
});

And in ashx file you can get the values as

int attId = Convert.ToInt32(context.Request.QueryString["qid"]);

in this way you can send more than one value in query string and get the values using the name of the querystring you are sending.

阅读全文

相关推荐

最新文章