jquery中ajax的data
时间:2014-06-03 09:19:37
收藏:0
阅读:219
常用的方法JSON.stringify(),JSON.parse()
1 JOSN.stringify(JsonObect) 这个函数是把Json对象转换成Json的字符串,如下
|
1
2
3
4
5
6
7
8
9 |
$.ajax({ type: "POST", url: "../WebService/xxx.asmx/Save", data: JSON.stringify({‘jsonObject‘: ‘hello‘}), contentType: "application/json; charset=utf-8", dataType: "json", error: function
() { alert(‘error!‘); }, success: function
(response) { alert(‘save success!‘); } }); |
在ajax中使用json对象给服务器传值的时候,对Json对象进行处理,而不用自己拼凑Josn的字符串
2 JSON.parse(Jsonstring)与JSON.stringify正好相反,是把Json的字符串转换成Json的对象
评论(0)