I am trying to call jQuery function when button is clicked. But I am getting the error as follows:
Uncaught ReferenceError: update_question_ajax is not defined
HTML:
<button type=button class=update-question-<?php echo $i; ?> button onclick=update_question_ajax(<?php echo $i; ?>) style=outline: 0 none;><?php _e('Update') ?></button>
jQuery:
$(function(){
function update_question_ajax(id)
{
var test = $('.edit-question-' + id + ' input[name=translated]');
var editedQuestionId = $('#question-id-'+id).val();
var editedQuestionObj = $('.edit-question-' + id + ' input[name=translated]').val();
var modalObj = $('#myQuestionModal');
$.ajax({
type: POST,
url: <?php echo base_url('admin/question/admin_edit_question'); ?>,
data:{
edited_question: editedQuestionObj,
question: editedQuestionId
},
success: function(){
modalObj.dialog('close');
modalObj.html('');
},
complete: function(){
//window.location.reload(true);
}
});
return false;
}
});
I appreciate if you guys help me out about this.
Thank you!