Ich muss eine AJAX-Variable in meine Sicht übergeben, so dass die form action
korrekt ausgeführt wird. Verwenden von Laravel 5.4. und meine (abgekürzt) sehen wie folgt aussieht:Wie man eine JS-Variable auf eine Laravel-Formularaktion anwendet
<div id="product_form" class="form-horizontal">
{{ Form::open(['action' => '[email protected]_product', // PRODUCT_ID MUST GO HERE]) }}
<div class=" form-group">
<div class="col-sm-2 col-md-2">{{ Form::label('product_name', 'Product Name:') }}</div>
<div class="col-sm-4 col-md-4">{{ Form::text('product_name',null) }}</div>
<div class="col-sm-2 col-md-2">{{ Form::label('product_id', 'Product Code') }}</div>
<div class="col-sm-4 col-md-4">{{ Form::text('product_id', null) }}</div>
</div>
Meine Ajax-Funktion alle Werte in die Formularfelder korrekt ist vorbei, aber ich kämpfen, um die product_id
in die richtige Stelle in der action-Anweisung zu erhalten. Laravel erwartet eine Variable zu sehen.
Ajax-Code (kurz):
select: function(event, ui) {
var product_id = (ui.item.value);
$.ajax({
url: "product_fullsearch/"+product_id,
dataType: "json",
type:"GET",
success: function (data) {
$('#product_name').val(data[0].product_name);
$('#product_id').val(data[0].product_id);
$("#supplier_name").val(data[0].supplier_name);
$("#supplier_id").val(data[0].supplier_id);
}
});//END AJAX
}
ich diese Pass JS variable to form action auf SO sah und gab ihm gehen, aber ich konnte es nicht in einem Laravel Kontext zu arbeiten.
Was mache ich falsch? Danke vielmals !