Parse JSON object created with PDO statement
Here is my problem
I have looked at Stak overflow and other websites, but cannot find an answer that solves my actual problem ...
I am calling php file from AJAX request, my php file gets data from my db.
I am making a pdo statement to get data from my db:
//initialize vars such as $db ...
$get = $db->prepare("SELECT * FROM myTable WHERE myTable_id=1");
$get->execute();
echo json_encode($get->fetchAll(PDO::FETCH_ASSOC));
//COLUMNS IN MY TABLE ARE ID, NAME, PHONE, INFO
so that the object is returned in my ajax request BUT I don't know how to get this object in my ajax / jquery statement to use its data ...
Response from console:
[Object{id="1",name="myname",phone="8888888",info="information"}]
code...
success : function(response){
var id = '';
var name = '';
var phone = '';
var info = '';
}
please tell me how to parse, i tried json.parse (answer) but cant display data from this ...
thank
+3
source to share