Laravel JS autocompletetrying to integrate ajax autocomplete in my create record in laravelErrors with event.preventdefaultJquery click trigger on Success or CompleteNo ajax response in laravel 4Pass input value to ajax get LaravelLaravel 5.1 Jquery $.get() not workingWhat is `HtmlString` used for in Laravel?$_POSt returns unexpected arraylaravel, ajax call from input to controller function 500 errortrying to Fetch Single record from table in laravel using ajax500 Internal server error while posting some data using AJAX in Laravel

What is the fundamental difference between catching whales and hunting other animals?

What's the big deal about the Nazgûl losing their horses?

In the Seventh Seal why does Death let the chess game happen?

How did the IEC decide to create kibibytes?

Taking my Ph.D. advisor out for dinner after graduation

How frequently do Russian people still refer to others by their patronymic (отчество)?

Sci-fi book (no magic, hyperspace jumps, blind protagonist)

Convert integer to full text string duration

Should I cheat if the majority does it?

A positive integer functional equation

The Purpose of "Natu"

Does the Milky Way orbit around anything?

How to deal with a Murder Hobo Paladin?

What is the highest level of accuracy in motion control a Victorian society could achieve?

Is it bad to suddenly introduce another element to your fantasy world a good ways into the story?

Is の方 necessary here?

How to reclaim personal item I've lent to the office without burning bridges?

Why did moving the mouse cursor cause Windows 95 to run more quickly?

Do intermediate subdomains need to exist?

What can a novel do that film and TV cannot?

Is it possible to spoof an IP address to an exact number?

Motorcyle Chain needs to be cleaned every time you lube it?

Initializing variables variable in an "if" statement

Sleepy tired vs physically tired



Laravel JS autocomplete


trying to integrate ajax autocomplete in my create record in laravelErrors with event.preventdefaultJquery click trigger on Success or CompleteNo ajax response in laravel 4Pass input value to ajax get LaravelLaravel 5.1 Jquery $.get() not workingWhat is `HtmlString` used for in Laravel?$_POSt returns unexpected arraylaravel, ajax call from input to controller function 500 errortrying to Fetch Single record from table in laravel using ajax500 Internal server error while posting some data using AJAX in Laravel






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I can't figure out what's going on here. I'm trying to make a pretty simple ajax post to do an autocomplete in laravel.



I have an input box and a spot for the results:



<div class="form-group">
<input type="text" name="tag_name" id="tag_name" class="form-control input-lg" placeholder="Enter Country Name" />
<div id="tagList">
</div>
</div>


and my JS



$('#tag_name').keyup(function() 
var query = $(this).val();
if(query != '')

//var _token = $('input[name="_token"]').val();
$.ajax(
url:" route('campaigns.search') ",
method:"POST",
data:query:query, _token: ' csrf_token() ',
success:function(data)
$('#tagList').fadeIn();
$('#tagList').html(data);

);

);

$(document).on('click', 'li', function()
$('#tag_name').val($(this).text());
$('#tagList').fadeOut();
);

});


The route points to my controller function:



 public function searchTags(Request $request)


if($request->get('query'))

$query = "%" . $request->get('query') . "%";
$data = CampaignTags::where('TAG_DATA', 'LIKE', $query)->get();

$output = '<ul>';
foreach ($data as $row)
$output .= '<li><a href="#">' .$row->TAG_DATA. '</a></li>';




return json_encode($data);



When I inspect as I type, I get 200 codes on the search but I'm not getting actual results to show from the database, the response seems to be null










share|improve this question
























  • Autocomplete shouldn't use POST. By definition it's not changing the state of anything except maybe for logging or analytics purposes, and is instead fetching data. A GET request would therefore be more appropriate.

    – Matthew Daly
    Mar 25 at 19:59











  • Hmm, I've only ever used POST for an autocomplete and that's how I've always seen it done. I thought it had to be post because I'm posting the query data to that endpoint

    – Tom N.
    Mar 25 at 20:00











  • Oh, sorry I missed your $query variable. Can you dd($search) to see if it's empty. Also can you change to $request->get('query') to $request->query. @MatthewDaly well theoretically true but doesn't matter in actual practice

    – senty
    Mar 25 at 20:01












  • Ah first problem: I have $search in my json encode but it should be $data. That change at least got the whole json object to show

    – Tom N.
    Mar 25 at 20:02











  • return repsonse()->json(['search' => $data]);

    – senty
    Mar 25 at 20:03

















0















I can't figure out what's going on here. I'm trying to make a pretty simple ajax post to do an autocomplete in laravel.



I have an input box and a spot for the results:



<div class="form-group">
<input type="text" name="tag_name" id="tag_name" class="form-control input-lg" placeholder="Enter Country Name" />
<div id="tagList">
</div>
</div>


and my JS



$('#tag_name').keyup(function() 
var query = $(this).val();
if(query != '')

//var _token = $('input[name="_token"]').val();
$.ajax(
url:" route('campaigns.search') ",
method:"POST",
data:query:query, _token: ' csrf_token() ',
success:function(data)
$('#tagList').fadeIn();
$('#tagList').html(data);

);

);

$(document).on('click', 'li', function()
$('#tag_name').val($(this).text());
$('#tagList').fadeOut();
);

});


The route points to my controller function:



 public function searchTags(Request $request)


if($request->get('query'))

$query = "%" . $request->get('query') . "%";
$data = CampaignTags::where('TAG_DATA', 'LIKE', $query)->get();

$output = '<ul>';
foreach ($data as $row)
$output .= '<li><a href="#">' .$row->TAG_DATA. '</a></li>';




return json_encode($data);



When I inspect as I type, I get 200 codes on the search but I'm not getting actual results to show from the database, the response seems to be null










share|improve this question
























  • Autocomplete shouldn't use POST. By definition it's not changing the state of anything except maybe for logging or analytics purposes, and is instead fetching data. A GET request would therefore be more appropriate.

    – Matthew Daly
    Mar 25 at 19:59











  • Hmm, I've only ever used POST for an autocomplete and that's how I've always seen it done. I thought it had to be post because I'm posting the query data to that endpoint

    – Tom N.
    Mar 25 at 20:00











  • Oh, sorry I missed your $query variable. Can you dd($search) to see if it's empty. Also can you change to $request->get('query') to $request->query. @MatthewDaly well theoretically true but doesn't matter in actual practice

    – senty
    Mar 25 at 20:01












  • Ah first problem: I have $search in my json encode but it should be $data. That change at least got the whole json object to show

    – Tom N.
    Mar 25 at 20:02











  • return repsonse()->json(['search' => $data]);

    – senty
    Mar 25 at 20:03













0












0








0








I can't figure out what's going on here. I'm trying to make a pretty simple ajax post to do an autocomplete in laravel.



I have an input box and a spot for the results:



<div class="form-group">
<input type="text" name="tag_name" id="tag_name" class="form-control input-lg" placeholder="Enter Country Name" />
<div id="tagList">
</div>
</div>


and my JS



$('#tag_name').keyup(function() 
var query = $(this).val();
if(query != '')

//var _token = $('input[name="_token"]').val();
$.ajax(
url:" route('campaigns.search') ",
method:"POST",
data:query:query, _token: ' csrf_token() ',
success:function(data)
$('#tagList').fadeIn();
$('#tagList').html(data);

);

);

$(document).on('click', 'li', function()
$('#tag_name').val($(this).text());
$('#tagList').fadeOut();
);

});


The route points to my controller function:



 public function searchTags(Request $request)


if($request->get('query'))

$query = "%" . $request->get('query') . "%";
$data = CampaignTags::where('TAG_DATA', 'LIKE', $query)->get();

$output = '<ul>';
foreach ($data as $row)
$output .= '<li><a href="#">' .$row->TAG_DATA. '</a></li>';




return json_encode($data);



When I inspect as I type, I get 200 codes on the search but I'm not getting actual results to show from the database, the response seems to be null










share|improve this question
















I can't figure out what's going on here. I'm trying to make a pretty simple ajax post to do an autocomplete in laravel.



I have an input box and a spot for the results:



<div class="form-group">
<input type="text" name="tag_name" id="tag_name" class="form-control input-lg" placeholder="Enter Country Name" />
<div id="tagList">
</div>
</div>


and my JS



$('#tag_name').keyup(function() 
var query = $(this).val();
if(query != '')

//var _token = $('input[name="_token"]').val();
$.ajax(
url:" route('campaigns.search') ",
method:"POST",
data:query:query, _token: ' csrf_token() ',
success:function(data)
$('#tagList').fadeIn();
$('#tagList').html(data);

);

);

$(document).on('click', 'li', function()
$('#tag_name').val($(this).text());
$('#tagList').fadeOut();
);

});


The route points to my controller function:



 public function searchTags(Request $request)


if($request->get('query'))

$query = "%" . $request->get('query') . "%";
$data = CampaignTags::where('TAG_DATA', 'LIKE', $query)->get();

$output = '<ul>';
foreach ($data as $row)
$output .= '<li><a href="#">' .$row->TAG_DATA. '</a></li>';




return json_encode($data);



When I inspect as I type, I get 200 codes on the search but I'm not getting actual results to show from the database, the response seems to be null







javascript php ajax laravel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 20:03







Tom N.

















asked Mar 25 at 19:53









Tom N.Tom N.

1,5576 silver badges20 bronze badges




1,5576 silver badges20 bronze badges












  • Autocomplete shouldn't use POST. By definition it's not changing the state of anything except maybe for logging or analytics purposes, and is instead fetching data. A GET request would therefore be more appropriate.

    – Matthew Daly
    Mar 25 at 19:59











  • Hmm, I've only ever used POST for an autocomplete and that's how I've always seen it done. I thought it had to be post because I'm posting the query data to that endpoint

    – Tom N.
    Mar 25 at 20:00











  • Oh, sorry I missed your $query variable. Can you dd($search) to see if it's empty. Also can you change to $request->get('query') to $request->query. @MatthewDaly well theoretically true but doesn't matter in actual practice

    – senty
    Mar 25 at 20:01












  • Ah first problem: I have $search in my json encode but it should be $data. That change at least got the whole json object to show

    – Tom N.
    Mar 25 at 20:02











  • return repsonse()->json(['search' => $data]);

    – senty
    Mar 25 at 20:03

















  • Autocomplete shouldn't use POST. By definition it's not changing the state of anything except maybe for logging or analytics purposes, and is instead fetching data. A GET request would therefore be more appropriate.

    – Matthew Daly
    Mar 25 at 19:59











  • Hmm, I've only ever used POST for an autocomplete and that's how I've always seen it done. I thought it had to be post because I'm posting the query data to that endpoint

    – Tom N.
    Mar 25 at 20:00











  • Oh, sorry I missed your $query variable. Can you dd($search) to see if it's empty. Also can you change to $request->get('query') to $request->query. @MatthewDaly well theoretically true but doesn't matter in actual practice

    – senty
    Mar 25 at 20:01












  • Ah first problem: I have $search in my json encode but it should be $data. That change at least got the whole json object to show

    – Tom N.
    Mar 25 at 20:02











  • return repsonse()->json(['search' => $data]);

    – senty
    Mar 25 at 20:03
















Autocomplete shouldn't use POST. By definition it's not changing the state of anything except maybe for logging or analytics purposes, and is instead fetching data. A GET request would therefore be more appropriate.

– Matthew Daly
Mar 25 at 19:59





Autocomplete shouldn't use POST. By definition it's not changing the state of anything except maybe for logging or analytics purposes, and is instead fetching data. A GET request would therefore be more appropriate.

– Matthew Daly
Mar 25 at 19:59













Hmm, I've only ever used POST for an autocomplete and that's how I've always seen it done. I thought it had to be post because I'm posting the query data to that endpoint

– Tom N.
Mar 25 at 20:00





Hmm, I've only ever used POST for an autocomplete and that's how I've always seen it done. I thought it had to be post because I'm posting the query data to that endpoint

– Tom N.
Mar 25 at 20:00













Oh, sorry I missed your $query variable. Can you dd($search) to see if it's empty. Also can you change to $request->get('query') to $request->query. @MatthewDaly well theoretically true but doesn't matter in actual practice

– senty
Mar 25 at 20:01






Oh, sorry I missed your $query variable. Can you dd($search) to see if it's empty. Also can you change to $request->get('query') to $request->query. @MatthewDaly well theoretically true but doesn't matter in actual practice

– senty
Mar 25 at 20:01














Ah first problem: I have $search in my json encode but it should be $data. That change at least got the whole json object to show

– Tom N.
Mar 25 at 20:02





Ah first problem: I have $search in my json encode but it should be $data. That change at least got the whole json object to show

– Tom N.
Mar 25 at 20:02













return repsonse()->json(['search' => $data]);

– senty
Mar 25 at 20:03





return repsonse()->json(['search' => $data]);

– senty
Mar 25 at 20:03












1 Answer
1






active

oldest

votes


















0














I did this using typeahead. and answered it in another thread. before



heres the link. Auto Complete Laravel






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345429%2flaravel-js-autocomplete%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I did this using typeahead. and answered it in another thread. before



    heres the link. Auto Complete Laravel






    share|improve this answer



























      0














      I did this using typeahead. and answered it in another thread. before



      heres the link. Auto Complete Laravel






      share|improve this answer

























        0












        0








        0







        I did this using typeahead. and answered it in another thread. before



        heres the link. Auto Complete Laravel






        share|improve this answer













        I did this using typeahead. and answered it in another thread. before



        heres the link. Auto Complete Laravel







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 21:41









        WebDev1125WebDev1125

        463 bronze badges




        463 bronze badges


















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345429%2flaravel-js-autocomplete%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현