dimanche 7 mai 2017

Uncaught RangeError: Maximum call stack size exceeded in AJAX call Laravel 5.4

I am trying to use AJAX in forgot password form. Before that I just tried to see a message in console but I'm getting Maximum cal stack size exceeded Error. I searched so many solutions and I came to know it is due to iterative call to a function without limiting condition but couldn't relate to my code.

enter image description here

HTML of form:

<form class="form-vertical" id="recoverform" role="form" method="POST">
                <input type="hidden" id="token" name="_token" value="">

                    <div class="controls">
                        <div class="main_input_box">
                            <span class="add-on bg_lo"><i class="icon-envelope"></i></span><input id="recover_email" type="email" name="email" placeholder="E-mail address" value="" required />
                        </div>
                    </div>

                <div class="form-actions">
                    <span class="pull-left"><a href="#" class="flip-link btn btn-success" id="to-login">&laquo; Back to login</a></span>

                    <span class="pull-right"> <button type="submit" class="btn btn-info">Recover
                    </button></span>
                </div>
            </form>

Javascript:

<script>
            jQuery( document ).ready( function( $ ) {
                $( '#recoverform' ).on( 'submit', function(e) {
                    e.preventDefault();
                    //var email = $('#recover_email').val();
                    //var host = "";
                    $.ajax({
                        type: "POST",
                        url: "",
                        data: { '_token': token },
                        dataType: 'json',
                        success: function (response) {
                        console.log('done');
                        }
                    });

                });
            });
        </script>

Route:

Route::POST('ajax', array('uses' => 'HomeController@ajaxTest'))->name('ajax');

Method in HomeController:

public function ajaxTest(){
        $response = array(
            'status' => 'success',
            'msg' => 'Setting created successfully',
        );
        return Response::json($response);  // <<<<<<<<< see this line
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire