简体   繁体   中英

Javascript: Can't access object properties from an Ajax call

i want to know how to access object response properties from a ajax call, i'm working with laravel 5.2 and Ajax, and i have this one:

$.get('/provider/'+provider_id+'', function(response){ 
            console.log(response); 
});

在此处输入图片说明

Yeah i tried with response = JSON.parse(response); but i got this error Uncaught SyntaxError: Unexpected token o in JSON at position 1(…) what's wrong?? or how i should to do? thanks!

As you can see from the console output, response is already an Object. No need to parse it again.

$.get('/provider/' + provider_id, function(response){ 
    var data = response.response;
    console.log("Email: " + data.email_p); 
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM