JSON.stringify( param)

在项目中遇到,通过ajax请求,将数组传递给后台。代码:

var searchJson==[{propertyName:"start_time",propertyType:"STRING",propertyValue:start_time,matchType:"GE"},{propertyName:"end_time",propertyType:"STRING",propertyValue:end_time,matchType:"LE"}];


$.ajax({

   url:"<%=request.getContextPath()%>/test/test_test.action",

  data:{searchJson:searchJson},

  type:"POST",

 success:function(data){}

});

POST传值如下:




这个一定不是想要的格式啊。网上各种查。。data代码修改如下:

data:{:JSON.stringify(searchJson)},

JSON.stringify的作用是:将value(Object,Array,String,Number...)序列化为JSON字符串



你可能感兴趣的:(JSON.stringify( param))