$(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