javascript - how to render ajax return in cakephp 3.1 -


i have table have checkboxes inside. after select how return sum of values table in modal before confirm form? , how render ajax response controller? in view

    $("#envia-vendas").ajaxform({   url: '../vendas/confirmar',    type: 'post',    success: function (data) {     $('#mymodal').modal('show');     console.log(data);   }, 

in controller

//dostuf             if($this->request->is('ajax')){               $sum = $sum;               $this->render('ajax/confirmado', 'ajax');               echo 'bal';               $this->set('text', 'test');               $this->set('_serialize', ['text']);              } 

how print result in view without reloading page?

what fiddle grabs of inputs, pops modal after values , names have been injected confirmation.

it should give starting point. setup give confirmation screen without need additional server calls.

just set action route want pass information server interactions.

html

<form id="test-form" method="post" action="your/action/here">   <input type="text" name="test" value="" />   <input type="submit" name="submit-form" value="submit" /> </form>  <div class="modal">   <div class="form-info-wrapper">    </div>   <a class="confirm">confirm information</a> </div> 

css

.modal {   position: fixed;   top: 0;   left: 0;   width: 100%;   height: 100%;   display: none;   background: #fff; } 

js

jquery(document).ready(function ($){     $('body').on('click', 'input[type=submit]', function (e) {     e.preventdefault();      var data = $(this).parent('form').serializearray();      $('.form-info-wrapper').empty();      for(_data in data)     {         $('.form-info-wrapper').append(data[_data].name + ': ' + data[_data].value);     }      $('.modal').fadein();   });    $('.confirm').click(function (e){         e.preventdefault();      $('#test-form').submit();   }); }); 

https://jsfiddle.net/ojaeacps/2/