jquery ajax传递参数为数值时配置

function  _functionservicecontentsave(projectid){
var datas=[]; 
$("[name='servercheck']").each(function(){
if(($(this).is(":checked")==true)){
datas.push($(this).val());
}
});


$.ajax({  
url:requestContextPath()+"prj-budget/servicecontent/save",
dataType: "json", 
traditional: true, //传送数组值
type: "POST",
data:{"datas":datas,
 "projectid":projectid},
success: function (data) {

   if(data.closeCurrent){
               _functionlayeralert(data.message,1,functioniframerefresh);
   }
}
});

}

traditional 
类型:Boolean
如果你想要用传统的方式来序列化数据,那么就设置为 true。所以如果要将数据作为参数传递时要设置为true。默认情况是false是不能传递数组。

猜你喜欢

转载自blog.csdn.net/builderwfy/article/details/77743685