It depends a lot on what you want todo with it, but this is a basic way of accessing the element keys. You can simply use the dot operator for each element key: "data.email" etc.
$.ajax({
type: 'POST',
url: 'support.php',
success: function(result) {
var data = jQuery.parseJSON(result);
alert(data.email);
}
});
INSERT INTO HTML ELEMENT:
I created a div with id="landingPad" and swapped out the alert line with:
$('#landingPad').html(data.email);
MAKE A LIST OF THE DATA RECEIVED:
Then I changed my div into an unordered list:
<ul id="landingPad"></ul>
After changing the success function, it listed all the data received from support.php:
$(document).ready(function(){
$.ajax({
type: 'POST',
url: 'support.php',
success: function(result) {
var data = jQuery.parseJSON(result);
$.each(data, function(index, value) {
$("#landingPad").append("<li>" + value + "</li>");
});
}
});
});
CREATE FORM ELEMENTS WITH AJAX DATA:
Next, I created the following form:
<form name="http://example.com/edit_my_values" action="post">
<div id="landingPad"></div>
<input type="submit" name="go" value="Edit Values"/>
</form>
Then by editing the AJAX, I created a form on the fly with the values received:
$(document).ready(function(){
$.ajax({
type: 'POST',
url: 'support.php',
success: function(result) {
var data = jQuery.parseJSON(result);
$.each(data, function(index, value) {
$("#landingPad").append('<input type="input" name="'+index+'" value="'+value+'"/><br/>');
});
}
});
});
INSERT DATA INTO AN EXISTING FORM:
Given the following form:
<form name="http://example.com/edit_my_values" action="post">
<label for="error">Error </label><input type="text" name="error"/><br/>
<label for="successInfo">Success </label><input type="text" name="successInfo"/><br/>
<label for="email">Email </label><input type="text" name="email"/><br/>
<label for="subject">Subject </label><input type="text" name="subject"/><br/>
<label for="description">Description </label><input type="text" name="description"/><br/>
</form>
You can fill your fields with AJAX data as follows:
$(document).ready(function(){
$.ajax({
type: 'POST',
url: 'support.php',
success: function(result) {
var data = jQuery.parseJSON(result);
$.each(data, function(index, value) {
$('[name='+index+']').val(value);
});
}
});
});