利用 ajax 像后台传递数组

来源:互联网 发布:拟线性偏好知乎 编辑:程序博客网 时间:2024/05/01 06:59

只需要添加一句话,轻松搞定:

traditional :true    //序列化数据

 function batchRemove(){var ids = new Array();$(".collect-goods-box").each(function(){var a = ($(this).find(".fl"));ids.push(a.attr("goodId"));});remove(ids);}//移除收藏function remove(id) {$.ajax({url : 'delete.do',traditional :true, //默认为false,官方解释:如果你想要用传统的方式来序列化数据,那么就设置为 true。详见 $.param()data : {'ids' : id},type : 'post',success : function(data) {console.log(data);if (data.code == 0) {window.location.href="list.do"} else {alert(data.msg);}}});}


0 0