Javascript Laravel PHP5输入:All()数组格式错误,偏移量未定义
非常简单的问题/任务只是在某个地方有一些我无法理解的错误 因此,我尝试从chrome扩展(使用jqueryJavascript Laravel PHP5输入:All()数组格式错误,偏移量未定义,javascript,php,jquery,ajax,laravel-5,Javascript,Php,Jquery,Ajax,Laravel 5,非常简单的问题/任务只是在某个地方有一些我无法理解的错误 因此,我尝试从chrome扩展(使用jquery$.ajax)向Laravel应用程序发出post请求 除了Laravel不能很好地处理POST请求负载外,其他一切都正常工作 我的ajax: $.ajax ({ type: "POST", url: 'https://old.example.com/data', dataType: 'json', //json ob
$.ajax
)向Laravel应用程序发出post请求
除了Laravel不能很好地处理POST
请求负载外,其他一切都正常工作
我的ajax:
$.ajax
({
type: "POST",
url: 'https://old.example.com/data',
dataType: 'json',
//json object below
data: arrayofproductsandthereassociates,
success: function () {
console.log(date);
ArrayOfProducts和TheResociates
已填充,如下所示:
var arrayofproductsandthereassociates = JSON.stringify({"Date":date,"Item":itemName,"Sold":sold,"Void":v0id,"Comp":comp,"Price":price,"Cost":cost,"Gross":gross,"Comps":comps,"Total Tax":totaltax,"Net":net,"Gross Proft":grossprofit,"Category":category});
当Laravel使用此控制器代码获取此有效负载时:
$input = Input::all();
print_r($input);
$itemz = json_decode($input[0]);
$model = new DATA;
foreach($itemz as $key => $value)
{
$model->$key = $value;
}
$model-save();
return;
它在json_解码($input[0])上出错代码>行,表示未定义的偏移量
在print\u r()
输出:
数组([{“日期”:“09-28-2016”,“项目”:“鲁本热”,“售出”:“1”,“无效”:“0”,“红利”:“0”,“价格”:“$2_35”,“成本”:“$0_00”,“毛额”:“$2_79”,“红利”:“$0_00”,“总税”:“$0_44”,“净额”:“$2_35”,“毛额”:“$2_35”,“类别”:“汤”=>[三明治”}=>)
我如何解决这个问题?我的感觉是数组中不匹配的=>
是我有未定义偏移量的原因?但我该如何解决这个问题呢
谢谢大家! 您能否显示,ArrayOfProductsandTheResociates
的字符串文本?不要使用stringify var ArrayOfProductsandTheResociates={“日期”:日期,“项目”:项目名称,“售出”:售出,“无效”:v0id,“成本”:Comp,“价格”:Price,“成本”:Cost,“总成本”:Gross;“Comps”:Comps,“总税”:totaltax,“净”:Net,“总利润”:grossproft:grossprofit,“类别”}@谢谢你,伙计!