Awesome q2a theme

Form of authorization. What is the error?

0 like 0 dislike
27 views
Good afternoon. Write your AJAX form on Bitrix. But I can't understand what the bug is, why when you click on the button "Request a call" nothing why something happens.

In footer.php created markup for the form itself.
Form callback


callback.php that lies at the root of the website folder ajax
< ? define("NO_KEEP_STATISTIC", true);?>
< ? define("NOT_CHECK_PERMISSIONS", true); ?>
< ? define("NEED_AUTH", true); ?>
< ? require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); ?>
< ?
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){

if(!empty($_POST['phone']) and !empty($_POST['name'])) {
$arEventFields = array (
"NAME" => strip_tags($_POST['name']),
"PHONE" => strip_tags($_POST['phone'])
);

if ($sended = CEvent::Send("CALLBACK", SITE_ID, $arEventFields)) {
$result['status'] = "success";
$result['message'] = "Your request successfully submitted";
} else {
$result['status'] = "error";
$result['message'] = "an error Occurred, please try again later";
}
} else {
$result['message'] = "Name and phone number required";
$result['status'] = "error";
}

exit(json_encode($result));
}
?>

ajax form submit
$(document).ready(function(){ $('#form-callback').on('submit', function(e) { $.ajax({ type: 'POST', url: $(this).attr('action'), data: $(this).serialize(), dataType: 'json', success: function(result){ if(result.status == 'success') { $('#form-callback').html(''+result.message+''); } if (result.status == 'error') { $('#form-callback .info-box').html(''+result.message+''); } } }); e.preventDefault(); return false; }) });

What's wrong here?
by | 27 views

1 Answer

0 like 0 dislike
F12, jamc, then submit, IAMC and look in the console, then tab Network - what's going on. Goes that goes that comes.

P. S. why so many times you open and close the PHP tags???
by

Related questions

0 like 0 dislike
1 answer
asked Apr 14, 2019 by Resident234
0 like 0 dislike
3 answers
0 like 0 dislike
2 answers
0 like 0 dislike
4 answers
110,608 questions
257,187 answers
0 comments
40,796 users