2014-07-06 126 views
0

我在AJAX響應中收到一些轉儲或附加字符。 這裏是我使用的代碼。ajax發佈數據返回值錯誤

form_data = 'source%5B%5D=email&nature_of_work%5B%5D=plumbing&requestor=asd&location_of_work=asd'; 
$.ajax({ 
    url: 'location_of_controller/sample', 
    type: 'POST', 
    data: {form_data:form_data}, 
    dataType: 'json', 
    success: function(res){ 
    console.log(res); 
    } 
}) 

對於控制器 我只是返回數據後。

function sample(){ 
    echo json_encode($this->input->post('form_data')); 
} 

這是輸出。

enter image description here

問題是,那爲什麼我收到

source ]=email&nature;_of_work[]=plumbing&requestor=asd&locati<br> 

,而不是

source%5B%5D=email&nature_of_work%5B%5D=plumbing&requestor=asd&location_of_work=asd 

回答

0

打開global_xss_filtering爲FALSE在配置 開放控制器/ congif.php

$config['global_xss_filtering'] = FALSE; 

但是這將關閉我猜的過濾安全性。