Created
March 8, 2017 05:42
-
-
Save jesuslerma/23645eebacd2adb9fc5f4c2d96b9ef84 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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