i want to submit my form using jquery ajax, it is ok but just for first time i click submit, here is my code.
<!-- input code from the form -->
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>" />
<!-- js code -->
$.ajax({
url: ajaxurls.ask,
type: 'POST',
data: formData,
contentType: false, // The content type used when sending data to the server.
cache: false, // To unable request pages to be cached
processData:false,
success: function (html) {
var data = jQuery.parseJSON(html);
if(data.status == 'ok') {
$('.row_question_form').after(data.response.html);
$('.question_' + data.response.question[0].question_id).hide().fadeIn();
$('#question_form').val('');
$('#thumbnails').empty();
$('#ask_question_messages').empty();
$('#ask_question_messages').html(data.message);
}else if(data.status == 'error'){
$('#ask_question_messages').empty();
$('#ask_question_messages').html(data.message);
}
}
});
You would probably say to set $config['csrf_regenerate'] = FALSE;
but in this case someone could create hundred of records in my database with a application like this: