0

Hi I can pass the data to Controller and tried to get processed data or array in controller to my view file using jQuery. I tried a lot to figure it out but not getting the data, error shows in console :

{"error":{"type":"ErrorException","message":"Trying to get property of non-object ..."}}

My stuffs are given below -

Controller :

public function addRow()
{
    if(Request::ajax()){
        $row = Input::all();        
    }
    return View::make('add-stock')
        ->with('rows', $row);
}

View:

@if( isset($rows) )
    @foreach($rows as $row)
    {{$row->row}}
    @endforeach
@endif
1
  • Just a note, $rows will always be set when you use ->with('rows') (even when it's empty). You may get better results checking for @if( !empty($rows) ) in your view. Commented Apr 3, 2015 at 19:09

2 Answers 2

2

It appears that there is no row property on your row object.

@if( isset($rows) )
    @foreach($rows as $row)

    // This is where your error is coming from
    {{$row->row}}

    @endforeach
@endif

Try leaving off the accessor, like this:

@if( isset($rows) )
    @foreach($rows as $row)

    {{ $row }}

    @endforeach
@endif
Sign up to request clarification or add additional context in comments.

4 Comments

Yes now error has removed in console , but I can't show it on view page @Ben Harold
You can't show what? What parameters are you passing to the script in your query string?
{{ $row }} is not appearing on view. how to show. actually i want to run loop with this $row value in php script
What is the output if you dd($row); right before you return View::make() in your controller?
0

Request::all() / Input::all() returns an array, not an object. And you are trying to access an array like an object. Use []

1 Comment

try using dd to get a dump of the data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.