我遇到了以下問題:我編寫了一個搜索函數,將結果保存到數組中。當我用jquery form plugin處理該函數的響應時,我創建了一個附加數組,該數組填充了搜索創建的所有數組。然後,我想將這個多數組解析爲我的jQuery腳本作爲JSON對象。到目前爲止這麼好,但我如何使多數組可訪問腳本? (像multiarray.array1.property)使用JSON和多維數組(JS)
這裏是到目前爲止我的代碼:
- [HTML/JS]
<!DOCTYPE html> <html> <body> <div class="edit"> <h2>Editieren</h2> <form id="suchen" method="post"><input type="text" id="search" name="id"> <input type="submit" value="Senden"></form> </div> </html>
$('#suchen').ajaxForm({
url: "./php/search.php",
dataType: 'json',
success: function(data){
alert(data[0]) ;
},
clearForm: true
}) ;
預先感謝您
編輯:
JSON的例子:
{
"id": "33",
"firma": "sls",
"strasse": "Industriegebiet Siebend",
"plz": "66663",
"ort": "Merzig",
"vorname": "",
"nachname": "Ruf",
"email": "[email protected] ",
"bemerkung": "",
"partner": "",
"kinder": "1",
"nation": "D",
"betreuer": "Adam",
"anrede": "Herr"
}
您能否提供生成的JSON樣本? –
當然,完成:) – Sprottenwels