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;
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
|
show 4 more comments
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
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 youdd($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
|
show 4 more comments
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
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
javascript php ajax laravel
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 youdd($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
|
show 4 more comments
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 youdd($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
|
show 4 more comments
1 Answer
1
active
oldest
votes
I did this using typeahead. and answered it in another thread. before
heres the link. Auto Complete Laravel
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
I did this using typeahead. and answered it in another thread. before
heres the link. Auto Complete Laravel
add a comment |
I did this using typeahead. and answered it in another thread. before
heres the link. Auto Complete Laravel
add a comment |
I did this using typeahead. and answered it in another thread. before
heres the link. Auto Complete Laravel
I did this using typeahead. and answered it in another thread. before
heres the link. Auto Complete Laravel
answered Mar 25 at 21:41
WebDev1125WebDev1125
463 bronze badges
463 bronze badges
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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