0

i can't send data to controller. my code is :

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);
    }
});

There is something wrong with the "data" ? thanks

Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106

1 Answers1

0

Check this it's definitely solve your issue

// 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);
    }
});

Hope you get your solution. any problem comment on box

ImBhavin95
  • 1,494
  • 2
  • 16
  • 29