【发布时间】:2015-11-09 09:52:53
【问题描述】:
我有一个 vue.js 脚本,它获取一个 csv,将其发送到我的服务器端代码,该代码将其分解为一个数组并将其发回。
现在,我将这些数据保存到一个数组中,以便客户端可以编辑任何数据并进行操作等。这是执行此操作的代码:
//hide the upload box, and display new message
$('#upload').slideUp();
$('#message').html('Cheers, Just give us a sec to decode the file...');
//get the file and save it into a new File Object ready to send
var files = $('input#csvUpload').prop('files');
var csv_file = new FormData();
csv_file.append('csv_file', files[0]);
//send to a controller that will read this file and return a JSON string!
this.$http.post('uploadCSV', csv_file, function(data){
//the data is the array returned from the controller,
//this function is just the call back
//now for the rows
this.rows = data.rows;
console.log(this.rows);
//update the message with some new instructions
$('#message').html("Done, now remove the cards you don't want to process");
//and show our table
$('#table').slideDown();
});
现在,一切正常。没有错。令人困惑的部分是,在最终用户完成更改后,我需要将该数据发送到将处理该数据的控制器。 但问题是当我发送数据时,当它到达控制器时,laravel 似乎无法找到它。
发送数据的代码:
this.$http.post('makePayment', this.rows, function(data){
this.processed = data;
console.log(data);
});
控制器代码:
$array = $request->all();
return $array;
exit();
我有一种感觉,它在盯着我的脸,但这真的让我很难过,上面的图片显示了 this.rows 对象中的内容。
提前感谢您的帮助!
【问题讨论】:
标签: javascript laravel-5.1 vue.js