i try to send data via PUT method, but Laravel 5.5 do not see any data inside Input (or Request) on destination controller.
Here JS:
function selectProject(option){
console.log('Update selected');
var data = new Object();
data.project_id = option.value;
data.user_id =;
console.log(data);
var url = "/admin/projects";
var xhr = new XMLHttpRequest();
xhr.open("PUT", url+'/update_selected', true);
xhr.setRequestHeader("X-CSRF-TOKEN", "");
xhr.onload = function () {
var response = xhr.responseText;
if (xhr.readyState == 4 && xhr.status == "200") {
console.log(response);
document.getElementById("app").innerHTML = response;
} else {
console.log(response);
document.getElementById("app").innerHTML = response;
}
}
xhr.send(data);
}
inside Laravel controller i try to showing inputs:
echo '[Controller]Inputs:';
return Input::all();
Here output from console.log:
Update selected
{…}
project_id: "4"
user_id: 1
__proto__: Object { … }
[Controller]Inputs:[]
Question: what i'am doing wrong and where is inputs data? p.s. I can use only pure javascript, no jQuery or anothers.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire