I am trying to show data which is passed from controller to blade and manipulate something with it in my view page. But I can see the my data passed correctly in my console but i am not getting it in my view file. I am using Laravel 4
Controller:
public function addRow()
{
if(Request::ajax()){
$row = Input::all();
}
return View::make('add-stock')
->with('rows', $row);
}
View :
@if( !empty($rows) )
@foreach($rows as $row)
{{ $row[0] }}
@endforeach
@endif
route:
Route::post('add-stock/row','StockController@addRow');
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>