Ajax GET request in laravel

Answers 1
  • Ajax call in laravel with GET method

    --PATH resources/views/<yourfile>.blade.php
        url: "{{ route('Ajaxgetrequestresp') }}",
        method: "GET",
        data: {id: 1},
        success: function(resp){
        error: function (xhr, ajaxOptions, thrownError) {

    Laravel ajax GET request method is used to send and receive data from the server without reloading the page. On the server side you can use the response() function with json() in your controller file to send response in json format to client, like  return response()->json(['msg'=>'This is a message from server']);

    You have to use jQuery library in your view file to use the ajax function. You can change url route and data parameters and values as per your requirement and after getting response you can display in your view file using DOM manipulation.

  • Back to code snippet queries related laravel