G
G
GaserV2016-04-05 19:58:18
Laravel
GaserV, 2016-04-05 19:58:18

Why is the view not returning?

Such situation. I implement live search on jq + laravel. Below is the client and server code. The server says "Class 'App\Http\Controllers\View' not found" . It's okay. But how to decide? At me it turns out when pressing a key, there is a request to a DB, the request transits and results are returned. When I return just $results, then I return data from the database, if I return it the way it is in the code now, then no. I generally display articles in a table. And as you type letters into the search, results are returned. It is necessary for me that they at once remained in the table. and what does not match the request - delete

$('.search-field').keypress(function(){
    var words = $(this).val();
    if (words.length > 1) {
      $.ajax({

        url: "/search",
        type: "post",
        data: {words: words},

        success: function(data) {
          console.log(data);
        }

      })	
    };
    
  })

public function search() 
  {
    $words = Request::get('words');
    $results = Articles::where('title', 'LIKE', '%' . $words . '%') -> first();
    return View::make('blog')->with('articles', $results);
  }

<div class="articles">
      @foreach($articles as $article)
      <div class="articles-row">
        <a href="/edit-article-{{ $article['id'] }}">
          {{ $article['title'] }}
          <span class="delete-icon" onclick="removeArticle()"></span>
          <span class="date">{{ $article['date'] }}</span>
        </a>
      </div>
      @endforeach
    </div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrzej Wielski, 2016-04-05
@wielski

use View;
Or use the construction \View::
If L5 - that is, the reduction -view('user.search')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question