2013-07-25 11 views
0

我在寫一個使用CodeIgniter將服務器腳本存儲到數據庫中的腳本。我的客戶端發送一個JSON包包含HTML字符串:

<table style='width:50%' 

但是從我的服務器端的我只能從$這個 - 獲取>後():

<table > 

你知道自己做錯了什麼?


我完全錯誤日誌:

我從客戶端(編碼從AngularJS由$ .PARAM)JSON:

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 

我的PHP代碼來處理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); 
    } 
} 

我從服務器上得到的東西:

<table >{"success":"update done","faqid":null,"index":false} 

預計faqid和index = null。它與錯誤無關。

我想這個錯誤是由於JavaScript編碼和PHP解碼JSON包的方式之間的區別?

+0

我的回答對你有幫助嗎? –

回答

0

我解決了$ _POST ['answer']替換$ this-> post('answer')的問題。

還是不知道發生的,但它的工作原理

+0

你可能想看看這個:http://stackoverflow.com/questions/3788476/codeigniter-disable-xss-filtering-on-a-post-basis 我很確定它必須與XSS清潔,所以你可以暫時禁用。 但更好的是沒有任何樣式標籤,也許你可以改爲使用CSS類。這不應該觸發XSS過濾器 – mgrueter

2

嘗試

$this->input->post() 

$this->post()

$ _ POST作品,因爲這就是原始的PHP函數

0
$this->post('answer'); 

應該是

$this->input->post('answer'); 
相關問題