JavaScript的:
Fatal Error: Uncaught Error: Call to a member function make() on null...
我看到 Chorme - >网络 - >标题 - >表格数据。
这里有完整数组。
我的PHP:
$.ajax({
headers: {'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')},
method: 'POST',
url: "{{URL::to('/person/mission/punch/import')}}",
data: {
form_year: selected_year,
forms: form.data
},
success: function () {
alert('success');
},
error: function () {
alert('fail');
}
});
无法转储完整的Array()。我用Laravel。
答案 0 :(得分:1)
您的索引值不正确,它必须是有效数据或json对象
data: {
form_year: selected_year,
forms: $("#formID").serializeObject();
},
我创建了一个jquery函数,它将序列化表单数据转换为json对象
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
的Javascript
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
$.ajax({
headers: {'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')},
method: 'POST',
url: "{{URL::to('/person/mission/punch/import')}}",
data: {
form_year: selected_year,
forms: $("form").serializeObject();
},
success: function () {
alert('success');
},
error: function () {
alert('fail');
}
});