加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

JSON.stringify( param)

发布时间:2020-12-16 19:22:20 所属栏目:百科 来源:网络整理
导读:在项目中遇到,通过ajax请求,将数组传递给后台。代码: var searchJson==[{propertyName:"start_time",propertyType:"STRING",propertyValue:start_time,matchType:"GE"},{propertyName:"end_time",propertyValue:end_time,matchType:"LE"}]; $.ajax({ url:

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

var searchJson==[{propertyName:"start_time",propertyType:"STRING",propertyValue:start_time,matchType:"GE"},{propertyName:"end_time",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字符串

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读