Skip to content

Instantly share code, notes, and snippets.

@jesuslerma
Created March 8, 2017 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesuslerma/23645eebacd2adb9fc5f4c2d96b9ef84 to your computer and use it in GitHub Desktop.
Save jesuslerma/23645eebacd2adb9fc5f4c2d96b9ef84 to your computer and use it in GitHub Desktop.
document.getElementById("btnAgrupar").onclick = enviar;
function enviar()
{
var token = '';
var arrayOfIds = [];
var allInputs = document.getElementsByTagName("input");
for (var i = 0, max = allInputs.length; i < max; i++)
{
if (allInputs[i].name === '_token') token = allInputs[i].value
if (allInputs[i].type === 'checkbox')
{
if (allInputs[i].checked)
{
arrayOfIds.push(allInputs[i].value)
}
}
} console.log(arrayOfIds)
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': token
}
});
$.ajax({
type: "POST",
url: "{{url('Material/Requisicion/agrupar')}}",
data: {'ids': arrayOfIds, },
success: function (data) {
// perform your save call here
if (data.status == "Success") {
alert("Done");
} else {
alert("Error occurs on the Database level!");
}
},
error: function () {
alert("An error has occured!!!");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment