hello From 2-3 days,iam stucked in a new problem,actually i have to retrieve information using 'api url' that retrieves complex json array which is just like this-
{"response":{"success":true,"result":{"id":"45203511","device_id":"62970","message":"Rs. 20.00 refunded in your Paytm wallet for your order on Paytm. Updated balance:Rs. 20.0. Queries? Visit Paytm.com\/care.","status":"received","send_at":0,"queued_at":0,"sent_at":0,"delivered_at":0,"expires_at":0,"canceled_at":0,"failed_at":0,"received_at":1507375388,"error":"N\/A","created_at":1507375388,"contact":{"id":"9209301","name":"VK-IPAYTM","number":"VK-IPAYTM"}}},"status":200}
I want to print an element from this json to console -
What I have tried:
My whole script part is:-
<script type="text/javascript"> var position ={}; $.ajax({ url:"my_api_url", type:"GET", success:function (data){ console.log(data.response.result.id); } }); </script>
It shows error :-
train2.php:23 Uncaught TypeError: Cannot read property 'result' of undefined at Object.success (train2.php:23) at i (jquery.min.js:2) at Object.fireWith [as resolveWith] (jquery.min.js:2) at A (jquery.min.js:4) at XMLHttpRequest.<anonymous> (jquery.min.js:4)