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'));
}
這是輸出。
問題是,那爲什麼我收到
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