2015-09-18 90 views
-1

如何從以下JSON獲取product_price值?獲取json響應的值php ajax

success: function(response){ 
    if (response.data.product_id == true) { 
     alert("Success"); 
     alert(response.data.product_price.val()); 
    { 
    "data": { 
     "product_id": true, 
     "product_price": "434", 
     "product_name": "yahoo", 
     "product_long_description": "asdfasdf", 
     "product_care": "yess", 
     "product_image": "\/easyinteriors\/public_html\/product_images\/144257317733697.jpg" 
    } 
} 

alert(response.data.product_price); 

我得到空值

+0

您需要提供您的整個JSON和整個AJAX功能 – CodeGodie

+0

我怎麼能做到這一點可以請你elobrate它 – user4464505

+0

你得到'響應值.data.product_price.value'? – jtheman

回答

0

如果要返回數據轉換成JSON格式。您需要解析響應

var json = $.parseJSON(response); 

然後alert(json.data.product_price);

+0

不,我想HTML值 – user4464505

+1

請詳細說明。 –