Ajax not working in laravel 5.6

Today, We want to share with you Ajax not working in laravel 5.6.In this post we will show you laravel api post request not working, hear for ajax url in laravel we will give you demo and example for implement.In this post, we will learn about laravel ajax response with an example.

Ajax not working in laravel 5.6

There are the Following The simple About request::ajax in laravel Full Information With Example and source code.

As I will cover this Post with live Working example to develop ajax is not a function laravel, so the laravel ajax get not working is used for this example is following below.

Laravel is a web application framework with expressive, elegant syntax.The PHP Framework for Web Artisans,freeing you to create without sweating the small things. CRUD Operation With Server Side.

Read Also:  Laravel 6 orderBy for Multiple columns

Keywords : $request- ajax() laravel not working,laravel ajax get not working,ajax post not working,ajax is not a function laravel,laravel api post request not working,ajax url in laravel,laravel ajax response,request::ajax in laravel,ajax request example laravel 5.7, laravel 5.7 ajax request example, jquery ajax in laravel 5.7, ajax post request laravel 5.7, laravel 5.7 ajax post data to controller, passing data from ajax to controller laravel 5.7, laravel 5.7 get ajax data

AJAX POST Request not working in Laravel 5.6


<meta name="token" content="{{csrf_token()}}">

var pass= {'_token':$('meta[name="token"]').attr('content'),
            'MessageContent': document.getElementById("sendproducts").value,

//Ajax call

        data: pass,
    }).fail(function(jqXHR, textStatus, error){

JQuery Ajax Post Request Example in Laravel

Create Routes for Ajax:routes/web.php

Route::get('ajaxRequest', '[email protected]');

Route::post('ajaxRequest', '[email protected]');

Create Controller in Laravel:


namespace App\Http\Controllers;
use Illuminate\Http\Request;
class MemberController extends Controller
     * Create a new controller instance.
     * @return void
    public function ajaxRequest()
        return view('ajaxRequest');
     * Create a new controller instance.
     * @return void
    public function jqAjaxRehttp(Request $request)
        $input = $request->all();
        return response()->json(['success'=>'Got Simple Ajax Request.']);

Create Blade File:


<!DOCTYPE html>
    <title>Laravel 5.6 Ajax Request example - www.pakainfo.com</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
    <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <meta name="csrf-token" content="{{ csrf_token() }}" />
    <div class="container">
        <h1>Laravel 5.7 Ajax Request example</h1>
        <form >
            <div class="form-group">
                <label>Member Name:</label>
                <input type="text" name="name" class="form-control" placeholder="Member Name" required="">
            <div class="form-group">
                <label>Member Password:</label>
                <input type="password" name="password" class="form-control" placeholder="Member Password" required="">
            <div class="form-group">
                <strong>Member Email:</strong>
                <input type="email" name="email" class="form-control" placeholder="Member Email" required="">
            <div class="form-group">
                <button class="btn btn-success btn-submit">Submit</button>
<script type="text/javascript">
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        var name = $("input[name=name]").val();
        var password = $("input[name=password]").val();
        var email = $("input[name=email]").val();
           data:{name:name, password:password, email:email},

Web Programming Tutorials Example with Demo

Read :

Read Also:  PHP Laravel AJAX Request GET and POST Example


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about ajax post not working.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  PHP Laravel 6 Sub-domain routing file Example
  2. Read Also:  Laravel Calculate Age from Date of Birth in MySQL
  3. Read Also:  jQuery Ajax POST example with Laravel 5.7
  4. Read Also:  jQuery Ajax Calling Laravel Example From Scratch
  5. Read Also:  Laravel 5.7 JQuery AJAX Tutorial Example
  6. Read Also:  Laravel 5.7 Queues Send Mail Tutorial With Example
  7. Read Also:  Eloquent ORM Soft Delete in Laravel 6
  8. Read Also:  Get Laravel Route Parameters
  9. Read Also:  Laravel Datatable Pagination Sorting and Search server side processing
  10. Read Also:  Laravel check if ajax request or not example