i'm using codeigniter 2.2 and working with signup form. I'm using ajax to validate username. i have enabled CSRF protection in codeigniter , after enabling CSRF i'm getting 500 Internal Server error, i have attached a image about this problem.
i think there could be some problem in my jquery
var cct = $("input[name=byzero_crack_stocks]").val();
$.ajax({
type: "post",
url: url+"ajax_register/username_check_ajax",
data: {
'username':$("#username").val(),
'csrf_token_name':cct,
},
but i can't find out.Help me out here.
add csrf token to data before posting
$.ajax({
type: "POST",
url: url+"ajax_register/username_check_ajax",
data: {'<?php echo $this->security->get_csrf_token_name(); ?>':'<?php echo $this->security->get_csrf_hash(); ?>','username':$("#username").val()}
})
csrf token needs to be send along every request so it needs to be specified by the above echo statements
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.