我想顯示從控制器傳遞到刀片的數據,並在我的查看頁面中使用它處理某些內容。但我可以看到我的數據在我的控制檯中正確傳遞,但我沒有看到它在我的視圖文件中。 我使用Laravel 4如何顯示從控制器傳遞到使用Laravel中的jQuery查看的數據
控制器:
public function addRow()
{
if(Request::ajax()){
$row = Input::all();
}
return View::make('add-stock')
->with('rows', $row);
}
查看:
@if(!empty($rows))
@foreach($rows as $row)
{{ $row[0] }}
@endforeach
@endif
路線:
Route::post('add-stock/row','[email protected]');
的jQuery:
<script>
$(document).ready(function(){
$('.rowForm').click(function(e){
e.preventDefault();
var rowVal = $('input[name=row]').val();
//ajax post
$.post('add-stock/row', {row:rowVal}, function(data){
console.log(data);
})
})
})
</script>
我怎麼能返回值到我想要的視圖? – WahidSherief 2015-04-04 09:18:10
你有什麼在「console.log(data);」? – mininoz 2015-04-04 09:21:20
不顯示 - {「error」:{「type」:「Symfony \\ Component \\ Debug \\ Exception \\ FatalErrorException」,「message」:「調用未定義的函數響應()」,「file」: 「C:\\ xampp \\ htdocs \\ easybiz \\ app \\ controllers \\ StockController.php」,「line」:93}} – WahidSherief 2015-04-04 09:21:57