basically my goal is to get all the json values into javascript / jquery variable so that i can show them on my html input fields. I am beginner in javascript so i cannot identify what i am doing wrong. Below is my function
// Update existing customers
$("#records").on('click', ".update", function() {
var data = $(this).attr('id');
var object = {};
$.ajax({
type: "GET",
url: "viewcustomers.php",
data: {update: data},
success: function(response) {
<!-- console.log(response);-->
object = $.parseJSON(response);
console.log(object.name);
So when i run this function i get a json response in my success: like below
"[{"id":"1","name":"ali","cnic":"01","address":"nipa","email":"301","phone":"luxairy "}]"
Now as per my understanding i tried to parse the response via jquery and take it in object. But when i am trying to console.log name or any other value its saying undefined.
Please help me understanding what i am doing wrong. Thank you. } });
[]indicates that you get an array (with 1 element in this exact case), as you can see here - json.org