Я работаю над проектом обмена с использованием laravel и хочу обновить sh мою таблицу после
<tbody class="fixed-header">
@foreach($transactionsCustomer as $transaction)
<tr>
<td>{{ $transaction->description }}</td>
@foreach($accounts as $account)
@if($transaction->code == 0)
@if($account->currency->id==$transaction->currency_id)
<td>{{ $transaction->amount }}</td>
<td></td>
@else
<td></td>
<td></td>
@endif
@else
@if($account->currency->id==$transaction->currency_id)
<td></td>
<td>{{ $transaction->amount }}</td>
@else
<td></td>
<td></td>
@endif
@endif
@endforeach
<td><a href="{{ route('transaction.edit',$transaction->id)}}" class="btn btn-primary" >سمون</a></td>
</tr>
@endforeach
</tbody>
, а вот мой код ajax для хранения данных
$("#transaction-form").submit(function(stay){
var formdata = $(this).serialize(); // here $(this) refere to the form its submitting
$.ajax({
type: 'POST',
url: "{{ route('transaction.store') }}",
data: formdata, // here $(this) refers to the ajax object not form
success: function (data) {
$('input[type="text"],textarea').val('');
updateTable();
},
});
stay.preventDefault();
});
и вот мой метод контроллера для представления данных
public function singleCustomer(Request $request)
{
$customer = Customer::find($request->id);
$accounts = Account::where('customer_id', $request->id)->get();
$currencies = Currency::all();
$transactionsCustomer = DB::table('transactions')->
join('accounts','transactions.account_id' ,'=','accounts.id')->join('customers','accounts.customer_id','=','customers.id')->join('currencies','accounts.currency_id','=','currencies.id')->select('transactions.*','currencies.id as currency_id')->where('customers.id',$request->id)->get();
return view('transaction.index',compact('currencies','customer','accounts','transactionsCustomer'));
}
Теперь я хочу обновить sh мою таблицу после этого ajax запроса