Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
How to pass double variable through laravel jquery? No response is shown on button click

I am trying to send a jquery request to update the table, that route requires two variables id, Receive_id. I tried this code below but the button on-click does not show any response. Plz review my code or suggest me if there are any other ways to send route. here is my blade code

<button data-url="{{ route('repairs.updateCylinder',['id'=> $cylinder->id, 'receive_id' => $data->id]) }}" class="btn btn-primary submit" id='update-cylinder'>Update</button> 

Here is Jquery code,

<script>
  $(document).ready(function(){

$(document).on("click", "#update-cylinder", function() { 
  // e.preventDefault();
var url = current.data('url')
 var id= 
$.ajax({
url: url,
type: "PATCH",
cache: false,
data:{
          _token:'{{ csrf_token() }}',
  body_leak: $('#body-leak').val(),
  nozzle_change: $('#nozzle-change').val(),
  nozzle_repair: $('#nozzle-repair').val(),
  cap_change: $('#cap-change').val(),
  washer_change:$('#washer-change').val(),
  wash:$('#wash').val(),
  refill:$('#refill').val(),
  remarks:$('#remarks').val()

},
success: function(dataResult){
          dataResult = JSON.parse(dataResult);
       if(dataResult.statusCode)
       {
          window.location = "/repairs/updateCylinder";
       }
       else{
           alert("Internal Server Error");
       }
  
}
});
}); 
});

</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can add a data-id on your button :

<button data-id="{{$cilinder->id}}" data-receive-id="{{ $data->id }}" class="btn btn-primary submit" id='update-cylinder'>Update</button> 

and on your script section :

     $("#update-cylinder").on("click", function(e) {
        e.preventDefault();
        let id = $(this).data("id");
        let receive_id = $(this).data("receive-id");
        let url = "repairs/updateCylinder/"+ id;
        let data = new FormData($('#id_form')[0]);   
        $.ajax({
           url: url,
           type: "PATCH",
           cache: false,
           data : data,
           datatype:'json',
           success: function(response){
           if(response.success == true){
               window.location "/repairs/cylinderlist";
           }else{
               alert("Error to update...");
           }
        });
    }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!