This question already has an answer here:
I want to send data from index.php
to the browser through AJAX. I want to encode it in JSON and to decode it to work on it. I am using jQuery.ajax()
. Can you point me to a tutorial?
</div>
This question already has an answer here:
I want to send data from index.php
to the browser through AJAX. I want to encode it in JSON and to decode it to work on it. I am using jQuery.ajax()
. Can you point me to a tutorial?
</div>
Assuming your ajax call looks something like this
$.ajax({
....
.....
dataType: 'json', // required
success: function(data) { // data variable is where your json is stored
console.log(data); // view entire json object in firebug or other console
alert(data.name); // access value of array key called name
}
});
I recommend placing a console.log
call in the success function to see what the json object looks like.