Trying to display record using Ajax

  ajax, javascript, laravel, php

i’m currently working on a movie database.
I’m trying to make a Pop-up form to edit movies category, i have tested using the console.log to check if when clicking in some movie the data where alright and it worked.


But now i need to send the data to the form inputs and i’m getting errors when trying to get the values.

Error $(‘name’).val()


<div class="modal fade" id="editModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
  <div class="modal-content">
    <div class="modal-header">
      <h5 class="modal-title" id="exampleModalLabel">Edit category</h5>
      <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<form method="post" action="{{ url('update-category') }}">
  <input type="text" name="category_id" id="category_id">
<div class="modal-body">
  <div class="col-auto">
    <label >Category name</label>
    <input type="text" class="form-control-plaintext" id="name" name="name">
    <div class="modal-footer">
      <button type="submit" class="btn btn-primary">Save</button>
      <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>

    $(document).on('click','.editbtn', function(){
        var category_id=$(this).val();

          success: function(response){
         //  console.log(;


public function edit($id){
    return response()->json([
        'status'=>200,  //value for test only


Source: Laravel

Leave a Reply