[ad_1]
‘);
return false;
}
if (EW_this.comment && !EW_hasValue(EW_this.comment, “TEXT”)) {
$(‘#commentsrequest’).html(‘
.لطفا متن پیام را وارد كنيد
‘);
return false;
}
var formData = {
‘name’: $(‘input[name=name]’).val(),
’email’: $(‘input[name=email]’).val(),
‘comment’: $(‘textarea[name=comment]’).val(),
‘g-recaptcha-response’: $(‘textarea[name=g-recaptcha-response]’).val(),
‘section’: $(‘input[name=section]’).val(),
‘item_id’: $(‘input[name=item_id]’).val(),
‘cource_id’: $(‘input[name=cource_id]’).val(),
};
$(‘#commentsrequest’).html(‘
‘);
// process the form
$.ajax({
type: ‘POST’, // define the type of HTTP verb we want to use (POST for our form)
url: ‘http://www.pnueb.com/account/save_comment’, // the url where we want to POST
data: formData, // our data object
dataType: ‘json’, // what type of data do we expect back from the server
encode: true
})
.done(function (data) {
// log data to the console so we can see
console.log(data);
$(‘#commentsrequest’).html(” “);
// here we will handle errors and validation messages
if (!data.success) {
// handle errors for name —————
if (data.errors.name) {
$(‘#commentsrequest’).append(‘
‘ + data.errors.name + ‘
‘); // add the actual error message under our input
$(‘input[name=name]’).focus();
}
// handle errors for email —————
if (data.errors.comment) {
$(‘#commentsrequest’).append(‘
‘ + data.errors.comment + ‘
‘); // add the actual error message under our input
}
if (data.errors.userCaptcha) {
/*$(‘#new_captcha’).prev().attr(‘src’, ‘http://www.pnueb.com/download/new_captcha?’ + Math.random());
$(‘input[name=userCaptcha]’).val(“”);
$(‘input[name=userCaptcha]’).focus();*/
$(‘#commentsrequest’).append(‘
‘ + data.errors.userCaptcha + ‘
‘); // add the actual error message under our input
}
} else {
// ALL GOOD! just show the success message!
EW_this.reset();
/*$(‘#new_captcha’).prev().attr(‘src’, ‘http://www.pnueb.com/download/new_captcha?’ + Math.random());
$(‘input[name=userCaptcha]’).val(“”);*/
$(‘#commentsrequest’).append(‘
‘ + data.message + ‘
‘);
}
});
// stop the form from submitting the normal way and refreshing the page
//window.event.preventDefault();
return false;
}
ارسال نظر
[ad_2]