$(document).ready(function() {
$.ajax({
type: 'POST',
url: 'http:abc/public/aditya/eJewelry/get_store_details.php?store_id=udb1001',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
alert(data);
}
});
});
我發送請求到該網址並獲得性反應: -jQuery的Ajax和JSON解析問題
[{
"id": "22",
"storename": "Unique Diamond Boutique",
"email": "[email protected]",
"storeimage_ipad": "",
"website": "www.uniquediamondboutique.com",
"store_code": "udb1001",
"street_address": "157 E New England Avenue\nSuite 202\n",
"country": "US",
"zipcode": "32789",
"state": "FL",
"city": "Winter Park",
"email_sales": "[email protected]",
"personal_phone": "407-312-6768",
"company_phone": "407-218-5958",
"image": "store_22.png",
"status": "1",
"paypal_email": "[email protected]",
"moreAddress": [{
"street_address": "123 main st",
"city": "MIAMI",
"state": "FL",
"zipcode": "33106",
"country": "",
"website": "",
"id": "68",
"company_phone": "",
"company_email": ""
}, {
"street_address": "640 Brevard Ave",
"city": "Cocoa Beach",
"state": "FL",
"zipcode": "32922",
"country": "",
"website": " ",
"id": "69",
"company_phone": "407-123-5678",
"company_email": " "
}]
}]
當我使用alert(數據)我得到「的翻譯:」;
我如何使用該數據來獲取ID,國家,email_sales..etc。
我使用alert(data.id),但得到空警報。如果您有任何想法,請讓我知道。
它是一個對象數組,因此數據[0] .id –
如果我找到了你,你想記錄所有的屬性,而不僅僅是ID,對吧?我添加了一個答案,列出了數據對象的所有屬性。 – Matt