首页 新闻 搜索 专区 学院

jquery ajax 提交数组值 获取是空值

0
悬赏园豆:40 [已解决问题] 解决于 2011-05-11 14:54

  function D() {
                var cks = document.getElementsByTagName("input");

                var a = new Array();
                for (var i = 0; i < cks.length; i++) {
                    if (cks[i].type == "checkbox" && cks[i].checked) {
                        a.unshift(cks[i].title);
                    }
                }
               $.ajax({
                    type: "get",
                    dataType: "text",
                    url: "../controller/Delete_message.ashx",
                    data: {"MeeageId":a},
                    beforeSend: function() { $("#HeadDiv").text("Send...").show("slow") },
                    complete: function() { $("#HeadDiv").text("Send end...").hide("slow"); },
                    success: function(msg) {
                        alert(msg);
                    }
                })
   
    }

后台代码:

       context.Response.Write( context.Request.Params["MessageId"])

  这样获取是空值  怎么办哦?

JIM.WEN的主页 JIM.WEN | 初学一级 | 园豆:14
提问于:2011-05-11 12:33
< >
分享
最佳答案
0

首先你要确定a在传过去的时候是有值的

传值方式如下:

data:{"MessageId":a.join(",")}
另:你用的是Get请求   取值时直接即可
Request.QueryString["MessageId"]

收获园豆:30
写代码的小2B | 老鸟四级 |园豆:4346 | 2011-05-11 13:17
function D() {
var cks = document.getElementsByTagName("input");

var arry = new Array();
for (var i = 0; i < cks.length; i++) {
if (cks[i].type == "checkbox" && cks[i].checked) {
arry.unshift(cks[i].title);
}
}
alert(arry.join(","));
$.ajax({
type: "get",
dataType: "text",
url: "../controller/Delete_message.ashx",
data: {"MeeageId":arry.toString()},
beforeSend: function() { $("#HeadDiv").text("Send...").show("slow") },
complete: function() { $("#HeadDiv").text("Send end...").hide("slow"); },
success: function(msg) {
alert(msg);
}
})

}
JIM.WEN | 园豆:14 (初学一级) | 2011-05-11 14:30
按你方法也是不行啊
里面是有值的
郁闷啊
JIM.WEN | 园豆:14 (初学一级) | 2011-05-11 14:31
其他回答(2)
0

data:{MessageId:a.toString()}

收获园豆:10
小彬 | 园豆:947 (小虾三级) | 2011-05-11 12:40
这样过去也是空值
支持(0) 反对(0) JIM.WEN | 园豆:14 (初学一级) | 2011-05-11 12:44
0

虽然你是个坟,挖一下吧,使用AJAX的traditional:true选项

A_DUST | 园豆:202 (菜鸟二级) | 2015-04-24 22:50
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册