Wednesday, June 24, 2015

laravel 5 ajax POST


hi guys here is basic AJAX POST on laravel 5 i hope this will help for your advance project

 thank you

Route::group(['prefix' => 'ajax'], function() {

    Route::get('/ajax', 'AjaxController@ajax');
    Route::post('/ajaxpost', 'AjaxController@ajaxpost');

<pre class="java" name="code">
             <input id="name" name="name" type="text" value="hello channa" />
             <input id="__token" name="__token" type="hidden" value="uAVNLARzB2zKp2hJElHXNRGSGLJ0gwqibXyqRXci" />

             <input class="submit" id="submit" type="submit" />

<div id="loadingmessage" style="display: none;">
<img src="loading.gif" />                                                                            
<div id="my_div">

        $('#loadingmessage').show();  // show the loading message.
            type: "POST",
            url: "http://localhost/bitbuckt/public/staff/ajaxpost",
            dataType: "html",
            data: { "_token" : "uAVNLARzB2zKp2hJElHXNRGSGLJ0gwqibXyqRXci" },
            success: function( response) {
              $('#loadingmessage').hide(); // hide the loading message



create view form under resources -&gt; view -&gt; ajax -&gt;ajax.blade.php
i passed _token key with data

create response action on AjaxController

    public  function ajaxpost()

        print_r('data response ');
    } public  function ajax()
        return view('staff.ajax');


1 comment:

  1. First of all, thank you for all the useful information. I would like to thank you for emphasizing the importance of playing an important role in the accommodation industry. I appreciate your hard work. Keep posting new updates with us.