Support the ongoing development of Laravel.io →
Input Database Eloquent
Last updated 2 years ago.
0

It's just standard ajax request from web browser.

You can use $.post(..) method of jQuery, to send POST request through ajax, and like u wrote you have to listen on "click" event on every checkbox u have on list.

I would go with something like Input boxes:

<input type='checkbox' data-taskid='4543' class='taskchecker'>
<input type='checkbox' data-taskid='1452' class='taskchecker'>
<input type='checkbox' data-taskid='8532' class='taskchecker'>

Then in javascript:

$(".taskchecker").on("change", function() {
   var taskId = $(this).attr("data-taskid"); // gets task ID of clicked checkbox
   var state = $(this).is(':checked'); // gets if checkbox is checked or not
   
  $.post("/changestatustask", {'idTask':taskId, 'checkboxStatus':state}, function() {
    // you can add some code here in response to ajax request
  );
});

This code is pretty simple and sloppy, and prolly have some mistakes, but should illustrate how can you to do it.

0

@lab6net

i think your method fit with my request but i have a problem:

i catch constantly a 405 error (method not allowed)....and i don't know why

0

Make sure checkbox (a value) isset, if not then 0 (zero).

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.