[英]Codeigniter : how to get process data with ajax and csrf
我無法將數據發送到控制器。 我的代碼是:
var csrf = Cookies.get('truelogokoption');
$.ajax({
url : baseURL +"checkout/hasilFilter",
type : "GET",
data : {destination: x, berat: y, courier: z} + "&starssecure=" + csrf,
success: function (ajaxData){
//$('#tombol_export').show();
//$('#hasilReport').show();
$("#hasil").html(ajaxData);
}
});
“數據”有問題嗎? 謝謝
檢查這肯定可以解決您的問題
// Add This Code in your current view php file
<input type="hidden" name="csrf_token" id="csrf_token" value="<?php echo $this->security->get_csrf_token_name(); ?>" />
<input type="hidden" name="csrf_token_value" id="csrf_token_value" value="<?php echo $this->security->get_csrf_hash(); ?>" />
// Change your js function according below
var csrf_token = $("#csrf_token").val();
var csrf_token_value = $("#csrf_token_value").val();
$.ajax({
url : baseURL +"checkout/hasilFilter",
type : "GET",
data : {destination: x, berat: y, courier: z, csrf_token: csrf_token_value},
success: function (ajaxData){
//$('#tombol_export').show();
//$('#hasilReport').show();
$("#hasil").html(ajaxData);
}
});
希望您能找到解決方案。 盒子上有任何問題評論
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.