How to prevent redirect with ajax request in a modal window?

Good afternoon. The essence is this:
There is a button that when clicked performs an ajax to send SMS to confirm the registration and then opens modelka with a field for entering this text. Inside moduli in addition to fields for entering the SMS submit button to confirm that submits the form. Here everything is OK.
It took in the same module add a button to request a new SMS with the timer. When you click the button you just need to implement ajax to the controller and some pregenerate Dunn, but the problem is that on click on this button instead of performing ajax request get a redirect to the previous page.
I understand modelka not particularly friendly with Ajax inside. How can I correct this action to by clicking on "Send new code" on the page, nothing changes, and just run the ajax?
In the code there is nothing new - bootstraps modelka and the event onclick with Ajax on the button to resend the code.
 'header' => '<div class="common__board-title-big" style="text-align: center; font-size: 18px;">To a specified number of SMS sent with a verification code. Enter the code in the box below. </div>',
 'toggleButton' => [
 'label' => 'Register',
 'tag' => 'button',
 'class' => 'guest__btn_submit modal-register register',
<div class="m-b-15 row">
 <div class="col-md-12 common__board-col" style="padding-left:30%; padding-right: 30%">
 <div class="form-group highlight-addon has-success">
 <?= Html::hiddenInput('hash-code', $hash_code, ['class' => 'hash-code']) ?>
 <?= Html::input('text', 'code', ", ['class' => 'modal-input', 'style' => "font-size: 25px; padding: 5% 20%; text-align: center;"]) ?>
 <div class="form-group">
 <?= Html::submitButton('Send', ['class' => 'btn-n-brd-lblue__fill send-button register']) ?>
 <div class="form-group">
 <?= Html::button('Get new code', ['class' => 'btn-n-brd-lblue__fill get_new_code', 'style' => 'display: none']) ?>
 <div id="timerBlock" class="common__board-title-big" style="text-align: center; font-size: 15px">
 <p>to Perezapustit code using <span class="seconds"> 10 </span> seconds</p>
<?php Modal::end(); ?>

$('.get_new_code').on('click', function(event) {
 var number = $('#profile-phone').val();
 var hash = $('.hash-code').val();
 url: '/registration/generate-new-hash',
 type: 'POST',
 data: {number : number, hash : hash},
 success: function(res){
 error: function(xhr, status, error){
April 19th 20 at 12:05
2 answers
April 19th 20 at 12:07
When you open modelki there say JS script to track the buttons in this module and send ajax to the server.
so I have a script that tracks the click on the button to resend the code. Only when the script comes directly to the Ajax page will redirected. If a block with Ajax comment, then everything is OK. - Trevion.Mertz commented on April 19th 20 at 12:10
April 19th 20 at 12:09
if only it were that simple - Trevion.Mertz commented on April 19th 20 at 12:12

Find more questions by tags Yii