how to show details of a specific id using datatable server side in jquery

how to show details of a specific id using datatable server side in jquery

waweru99 karanjawaweru99 karanja Posts: 13Questions: 4Answers: 0

i have houses and their able to display all the houses in a datatable.i have a column in the datable whereby a user clicks and they are redirected to another page with all the house is where a small bug that am unable to understand.on the details page the houses of the details are being displayed in a datatable.i want to pass the id of the house to the house details datatable function so that i can pass it to the route.i have tried this but i get a route not defined error, meaning the id isn't being passed. here is my jquery code.

// show all rental details of the house in a datatable

        var hseid=$('#house_id').val();

        var rentaldetailstable = $('#rentaldetailstable').DataTable({


        ajax:'{{ route("get_rentaldetails/' + hseid '") }}', //the hseid here isnt passed
        columns: [
          { data: 'id' },
          { data: 'image',
              render: function ( data, type, full, meta, row) {
                  return "<img src=\"/imagesforthewebsite/alternateimages/small/" + data + "\" height=\"80px\" height=\"80px\"/>"
          { data: 'status',name:'status',orderable:true,searchable:true },
          { data: 'delete',name:'delete',orderable:false,searchable:false },



  • kthorngrenkthorngren Posts: 16,808Questions: 25Answers: 3,984

    //the hseid here isnt passed

    What is passed?

    Have you used the browser's network inspector to look at the XHR request to see what is passed?

    var hseid=$('#house_id').val();

    Have you validated this is working correctly?

    I suspect that the URL in line 11 is built with whatever value hseid contains from line 2. This isn't dynamic, meaning when Datatables is initialized it will use the value in hseid to build the URL and this URL is static so it won't change later if the value changes.

    If you need this to be dynamic then you will want to use as a function so it can pass dynamic values.

    If this doesn't help please post a link to your page or a test case replicating the issue so we can help debug. There isn't enough information to provide more specific suggestions.


Sign In or Register to comment.