I'm basic at javascript, so please help me. I have a function, which select (onchange) every city for the countys. I have to add csrf token to the post.
The default function which is working great, but needed CSRF.
function getcitydetails(id) {
$.ajax({
type: "POST",
url: base_url + "fanok/ajax_city_list/" +id,
data: id='city_county_code',
success: function(data){
$('#user_city').html(data);
},
});
}
And there is one I have tried.
function getcitydetails(a) {
var b = {
id = a
}
b[csfr_token_name] = $.cookie(csfr_cookie_name);
$.ajax({
type: "POST",
url: base_url + "fanok/ajax_city_list/" +id,
data: b[id]='city_county_code',
success: function(data){
$('#user_city').html(data);
},
});
}
Which is fail to work :/
Help me please.
Thanks in advance.