I am getting the json data that i am sending to display in a div by append but i want to save that data to a variable so that i can use it even after page reload
here is my code
jQuery('#npost').submit(function(e){
e.preventDefault();
var formData = new FormData(this);
var url= '<?php echo base_url("user/postData"); ?>';
jQuery.ajax({
type: "POST",
url:url,
data: formData,
dataType: 'json',
cache: false,
contentType: false,
processData: false,
success: function(data)
{
var ParsedObject = JSON.stringify(data);
var json = $.parseJSON(ParsedObject);
alert(json.status);
var value= json;
json.textdata;
//$("#status_data").val(json.textdata);
$('#result_table').append(json.textdata);
},
error: function(data){
//error function
}
});
});
here is my controller
public function postData()
{
$post = $this->input->post();
//print_r($post);
unset($post['submit']);
$this->load->model('Pmodel');
$post_data=$this->Pmodel->post_data($post);
echo json_encode($post);
}
view
<div id='result_table' style="color:white;">
<?php echo $status; ?><br>
</div>
can i save the data in a html element and echo it in the controller or is it possible to save it in the view ?