Laravel search data with AKAX

this is my ajax code, i want to type something in textbox, and the result from database will show at the table..

<script type="text/javascript">
  function retrieve(){
    var country = $('#country_name').val();
      type: "POST",
      url: '{{route('dataAjax-country')}}',
      data: {country:country},
      success: function(result){

but the data is not change when i type on my textbox, i have a textbox and a table like this..

{!! Form::text('country_name', '', array('id'=>'country_name', 'onkeyup'=>'retrieve()')) !!}

<tbody id="ajaxtable">
  @foreach($results as $result)

and this is my route code, maybe i lack at my route(?):

Route::get('asd', array(
        'as' => 'dataAjax-country', 'uses' => 'CompaniesController@dataAjaxCountry'));

and my controller that contain AJAX script tah will show at the table:

public function dataAjaxCountry()
    echo "<tr><td>asdsad</td></tr>";

Source: laravel

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.