I m retrieving some json data from database....and want to print that in html output...
Basically i need html output of json data...
ho can i convert json to html.....
my ajax code by which i am getting json data..
show = function (id){
$.ajax({
type: "POST",
url: ajax_url_print,
data: "action=load&id="+id,
success: function(data) {
var data1 = JSON.parse(data)
// i need here output in html..and want to show on html by id
},
error: function() {
//alert('some error has occured...');
},
start: function() {
//alert('ajax has been started...');
}
});
}
my php code
public function getData(){
if($this->input->post('action') == 'load') {
$id = $this->input->post('id');
if($id !=''){
$query = "SELECT VIEWS FROM wl_views WHERE ID = $id ";
$row = $this->db->query($query);
$res = $row->result();
$result = $res[0]->VIEWS;
header('Content-Type: application/json');
echo json_encode(stripslashes($result));
}
}
}
my json return format
{"title":"gift1","elements":[{"title":"Any Text","source":"Default Text","parameters":{"x":243,"y":181,"colors":["#000000"],"removable":true,"draggable":true,"rotatable":true,"resizable":true,"scale":1,"degree":0,"price":0,"boundingBox":false,"source":"Default Text","originX":243,"originY":181,"currentColor":"#000000","text":"Default Text","font":"Arial","textSize":18}},{"title":"gift1","source":"http://localhost/amazon/uploaded_files/thumb_cache/thumb_600_300_gift173OO.jpg","parameters":{"x":100,"y":81,"colors":false,"removable":false,"draggable":false,"rotatable":false,"resizable":false,"scale":1,"degree":0,"price":0,"boundingBox":false,"source":"http://localhost/amazon/uploaded_files/thumb_cache/thumb_600_300_gift173OO.jpg","originX":100,"originY":81,"originWidth":400,"originHeight":300,"width":400,"height":300}}]}