[英]Javascript stringed array into an actual array
行。 所以標題聽起來令人困惑,但這可能是描述它的最佳方式。
我正在使用TextExt jQuery 插件在表單中創建標簽列表。 但是,插件在提交時會在字符串中創建一個數組。 例如。 "["this","that","other"]"
。
如何將其轉換為實際數組? ["this","that","other"]
提示我完全忽略了非常簡單的答案。
由於您使用的是 jQuery,您可以像這樣通過jQuery.parseJSON傳遞它:
var array = jQuery.parseJSON('["this","that","other"]')
看起來像JSON 。 因此,當您已經包含 jQuery 時,請使用JSON.parse()
或更好jQuery.parseJSON()
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.