I am writing a server script using CodeIgniter to store html code into database. My client send a json package contain a html string:
<table style='width:50%'
but from my server side I can only get from $this->post():
<table >
Do you know what wrong?
My full error log:
My JSON from the client side (encode by $.param from AngularJS):
apikey=superrocket_51f0c7333392f&faqid=31&categoryid=44&question=How+to+format+the+answer+%3F&answer=%3Ctable+style%3D'width%3A50%25%3B'%3E&displayorder=0
My PHP code to handle the JSON:
function updateFAQs_post(){
$auth = $this->_auth();
if ($auth){
print_r($this->post('answer'));
$this->load->model('Admin_model');
$faqid = $this->Admin_model->updateFAQs($this->post('faqid'), $this->post('categoryid'), $this->post('question'), $this->post('answer'), $this->post('displayorder'));
$response = array('success' => 'update done', 'faqid' => $faqid, 'index' => $this->post('index'));
$this->response($response, 200);
}
}
What I get from server:
<table >{"success":"update done","faqid":null,"index":false}
The faqid and index = null is expected. It has nothing to do with the error.
I think the error is due to the difference between the way JavaScript encode and the way PHP decode JSON package ?