私はLaravelの新機能で、JQueryの新機能もありますので、ぜひご利用ください。私の意見の一つで、私は、フォーム持っているので:LaravelのコントローラーでJSONを処理する
<table id="tblAShip" class="report table table-condensed table-hover table-sorter">
<thead class="no-sort">
<tr>
<th>Height</th>
<th>Width</th>
<th>Length</th>
<th>Weight</th>
<th>Create parcel</th>
</tr>
</thead>
<tbody>
<tr>
<td><input id="height" name="height" type="number" /></td>
<td><input id="width" name="width" type="number" /></td>
<td><input id="length" name="length" type="number" /></td>
<td><input id="weight" name="weight" type="number" /></td>
<td><input type="button" name ="creatShip" id="creatShip" value="Ajouter"></td>
</tr>
</tbody>
を次にこのフォームはAjax呼び出し
function creerParcel(){
var docNum = $("#commandeNum").val();
var hei = $("#height").val();
var wid = $("#width").val();
var len = $("#length").val();
var wei = $("#weight").val();
$.ajax({
type: "POST",
url: "/EasyPostNetBanks/Shipment/"+docNum,
contentType: "application/json; charset=utf-8",
processData: false,
data: {
"Parcels":[{
"length": len,
"width": wid,
"height": hei,
"weight": wei }]
},
error: function(jqXHR, textStatus, errorThrown)
{
},
success: function(data){
}
});
を作るJSによって処理され、その後、私のコントローラで私が盗ん行くしてみてくださいこのデータは私のAjaxコールから入手した荷物情報を持つ貨物を作成するためのものです
foreach(\Input::get('Parcels') as $parcelInfo)
{
$parcel = $this->CreateParcel($parcelInfo);
$shipment = Shipment::create(array(
"to_address" => $to,
"reference"=>$idCommande,
"from_address" => $from,
"parcel" => $parcel,
"options" => array("label_format" => "ZPL")
));
$ship = \Shipments::creer($shipment);
$shipments[] = $ship;
}
しかし、私の\ Input :: ge t( 'Parcels')は常にNULLです。\ nどのように可能ですか?私はほとんどすべて私がオンラインで見つけることができたが役に立たなかったので、私は(最初の投稿BTW。
ネットワークテーブルにエラー500が表示されます。入力が不足しているため、dd(Input :: all())が機能しません。 (2、 'Invalid argumen ...'、 '/ var/www/EasyPo ...'、85、Array)を使用している場合は、 – Markasius