javascript - Displaying specific Key Value Pair -
hi have form has email , password , upon clicking submit button puaru_active() function runs given below
<script> function puaru_active() { var http = new xmlhttprequest(); var tk = document.getelementbyid("tk").value; var mk = document.getelementbyid("mk").value; var url = "iphone.php"; var params = "u="+tk+"&p="+mk+""; http.open("post", url, true); http.setrequestheader("content-type", "application/x-www-form-urlencoded"); http.onreadystatechange = function() { if(http.readystate == 4 && http.status == 200) { console.log(http.responsetext); } } http.send(params); } </script>
on console.log displays json data
{"session_key":"5.e3jua_tvpguaea.1492179678.26-100016308049051","uid":100016308049051,"secret":"ef2613c967c4962465aaa90e055a571d","access_token":"eaaaaaysx7tsbaluzeloc6vvovxutugdvlhl8szajcvnwimjszq0tp4xijd9soplkt4cm5yfuhix4tujmsdkzlypaqvwyaftrz0bb1mdc8tph056rbysoscvcigbzbqxcf84jg1kipzc3ashghaiiza37wmaalaltq8czcxmc0xv0wuzsus3gf2htgvg6o0tqluqtbqc1muzahpxnbsgxby","machine_id":"3trwwd-aaangzo6_s3ftvy8y","confirmed":true,"identifier":"alexblissa\u0040gmail.com"}
now want output access_token , value how should that?
i have tried:
console.log(http.responsetext.access_token) console.log(http.responsetext['access_token']) console.log(http.access_token) console.log(responsetext.access_token)
both none of them working can tell me how achieve this? thank you!
first parse json string, access object.
var response = json.parse(http.responsetext); console.log(response['access_token']);
Comments
Post a Comment