search

Home  >  Q&A  >  body text

javascript - How can ajax pass two values, a JSON.stringify (object) and an array to the background java Controller?

When passing values, can Channels be passed through data together?
var Channels=new Array();

        $("input:checkbox[name=websiteChannel]:checked").each(function(i){
            if($(this).val()=="其他"){
                Channels[i]=$("#fuxuankuang").val();
            }else{
                Channels[i]=$(this).val();
            }

if(checkOrder()){

            confirm('确定要提交备案吗?', function(){
                $.ajax({
                    type: "POST",
                    url: url,
                    data: JSON.stringify(vm.websiteApplyOrder),
                    success: function(r){
                        if(r.code === 0){
                            alert('操作成功', function(index){
                                location.href='/website/applyOrder/website_apply_order.html';
                            });
                        }else{
                            alert(r.msg);
                        }
                    }
                });
            });
        }
怪我咯怪我咯2731 days ago892

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-06-12 09:33:58

    data: {
        "json": JSON.stringify(vm.websiteApplyOrder),
        "channel": Channels
    }

    Just pass the key-value pair directly, jQuery/Zepto will do the conversion process

    reply
    0
  • Cancelreply