Answer the question
In order to leave comments, you need to log in
Review validation, need help adding js, can't figure out how to do it?
Hello.
When writing a review and sending it, it used to work like this, when I wrote and sent it, it redirected to the page where there was an inscription that the review was sent and is waiting for the moderator to check.
Right now it's done through js, but not completely, validation without reloading, and when you click send, the review goes to check, but there is no inscription, how to display the inscription? tell me that the inscription is displayed and the forms form with filled fields is clean.
Here are the actions:
public function action_index()
{
if (Request::current()->method() == 'POST')
{
$data = $_POST;
if (Captcha::valid($_POST['captcha']))
{
$data['ip'] = $_SERVER['REMOTE_ADDR'];
ORM::factory('reviewssite')->values($data)->create();
$this->request->redirect('reviewssite/do');
}
else
{
$errors = "Не правильно ввели код с картинки";
}
}
$captcha = Captcha::instance();
$reviews = ORM::factory('reviewssite')->where('status', '=', 1)->order_by('id', 'DESC')->find_all();
$this->template->content = View::factory('index/page/reviews')
->bind('errors', $errors)
->bind('reviews', $reviews)
->bind('captcha', $captcha)
->bind('data', $data);
$this->template->site_name = "Отзывы";
}
public function action_do()
{
$this->template->content = View::factory('index/page/reviews_do');
$this->template->site_name = "Отзывы";
}
}
<script type='text/javascript'>
$('#otzivpredlog').submit(function() {
var obj = this;
var check = checkForm(obj);
if (check) {
$.post($(this).attr('action'), $(this).serialize(), function(r) {
if (r.error) {
$(obj).find('#validationka').html(r.error).show();
}
if (r.ok) {
$(obj).html(r.ok);
}
}, 'json');
}
return false;
});
</script>
<form method="POST" id="otzivpredlog">
тут поля для заполнения.
</form>
if (r.ok) {
$(obj).find('#validationka').html('Ваш отзыв отправлен на проверку, после проверки будет добавлен на сайт.').show();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question