利用 ajax 像后台传递数组

    xiaoxiao2025-07-16  6

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

    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); } } }); }

    转载请注明原文地址: https://ju.6miu.com/read-1300764.html
    最新回复(0)