I have an Array var cars = [2,3,..]
which holds a few integers.
(我有一个数组var cars = [2,3,..]
,其中包含一些整数。)
.get
method. (我已经向数组添加了一些值,但是现在我需要通过jQuery的.get
方法将此数组发送到页面。)
(如何将其转换为JSON对象进行发送?)
ask by dotty translate from so I have an Array var cars = [2,3,..]
which holds a few integers.
(我有一个数组var cars = [2,3,..]
,其中包含一些整数。)
.get
method. (我已经向数组添加了一些值,但是现在我需要通过jQuery的.get
方法将此数组发送到页面。)
(如何将其转换为JSON对象进行发送?)
ask by dotty translate from soScript for backward-compatibility: https://github.com/douglascrockford/JSON-js/blob/master/json2.js
(向后兼容的脚本: https : //github.com/douglascrockford/JSON-js/blob/master/json2.js)
And call:
(并致电:)
var myJsonString = JSON.stringify(yourArray);
Note: The JSON object is now part of most modern web browsers (IE 8 & above).
(注意: JSON对象现在是大多数现代Web浏览器(IE 8及更高版本)的一部分。)
See caniuse for full listing.(有关完整列表,请参见caniuse 。)
Credit goes to: @Spudley for his comment below(感谢:@Spudley在下面的评论)