Hussam7102 Posted October 13, 2016 Share Posted October 13, 2016 Javascript: $getJSON("path", function(data){alert(data.name)}) Guys in this line "data" is not working as an object. name is unrecognizable here. I am sending multiple outputs in php using json_encode() function but not able to get those values in javascript file. PHP Code: $book = array("name"=>"Hussam", "num"=>1); echo json_encode($book); Quote Link to comment https://forums.phpfreaks.com/topic/302323-not-getting-return-values-in-getjson-object/ Share on other sites More sharing options...
codefossa Posted October 13, 2016 Share Posted October 13, 2016 You are missing the period for $.getJSON(). If that's not your issue, you should check your JS console to see if you're failing to parse the return. Maybe output the return in your console and see what that is. You can just do a $.get() and $.parseJSON() if you want to be able to output the data as well as parse it. Quote Link to comment https://forums.phpfreaks.com/topic/302323-not-getting-return-values-in-getjson-object/#findComment-1538242 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.