Why does jQuery script make values loaded in input object to disappear?Understanding and implementing jQuery autocomplete with AJAX source and appendToWhy does the jquery change event not trigger when I set the value of a select using val()?How to set value of input text using jQueryWhy does jQuery or a DOM method such as getElementById not find the element?jquery - Get multidimensional array form input valuexing / wysihtml5 unescapes < and >Jquery Not Grabbing Newest Input ValueJquery toggle input value and button classI want to make a Javascript browser scripts in console. What syntax is there to click/enter text/find values?Ajax/PHP - autocomplete value not recognisedajax call based on the value of 2 input fields to populate jquery autocomplete

Why can't we play rap on piano?

Does the Idaho Potato Commission associate potato skins with healthy eating?

What reasons are there for a Capitalist to oppose a 100% inheritance tax?

What do you call someone who asks many questions?

Am I breaking OOP practice with this architecture?

What are some good books on Machine Learning and AI like Krugman, Wells and Graddy's "Essentials of Economics"

Why no variance term in Bayesian logistic regression?

Why didn't Boeing produce its own regional jet?

Apex Framework / library for consuming REST services

Ambiguity in the definition of entropy

Is it logically or scientifically possible to artificially send energy to the body?

Personal Teleportation: From Rags to Riches

I would say: "You are another teacher", but she is a woman and I am a man

Do scales need to be in alphabetical order?

Alternative to sending password over mail?

Could the museum Saturn V's be refitted for one more flight?

Madden-Julian Oscillation (MJO) - How to interpret the index?

What killed these X2 caps?

Method Does Not Exist error message

How dangerous is XSS?

What exploit Are these user agents trying to use?

How can saying a song's name be a copyright violation?

Extract rows of a table, that include less than x NULLs

What about the virus in 12 Monkeys?



Why does jQuery script make values loaded in input object to disappear?


Understanding and implementing jQuery autocomplete with AJAX source and appendToWhy does the jquery change event not trigger when I set the value of a select using val()?How to set value of input text using jQueryWhy does jQuery or a DOM method such as getElementById not find the element?jquery - Get multidimensional array form input valuexing / wysihtml5 unescapes < and >Jquery Not Grabbing Newest Input ValueJquery toggle input value and button classI want to make a Javascript browser scripts in console. What syntax is there to click/enter text/find values?Ajax/PHP - autocomplete value not recognisedajax call based on the value of 2 input fields to populate jquery autocomplete













0















So, I have a search bar on my site:



<form action="" method="GET" class="form-inline justify-content-center">
<input type="text" id="s_bar2" name="search" size = "75" class="form-control mr-sm-2" aria-label="Search">
<input class="btn btn-outline-primary my-2 my-sm-0" type="submit" value="Search">
</form>


And after a search is executed, I maintain the query in the bar by pulling it from the URL using this script:



 <script type="text/javascript">
var elem = document.getElementById("s_bar2");
const urlParams = new URLSearchParams(window.location.search);
elem.value = urlParams.get('search');
</script>


However, the previous query only appears in the search box for a few milliseconds before vanishing. I have pinpointed the issue to my script:



 $(document).ready(function() 
$("#s_bar2").autocomplete(
source: "/policy_suggest/"
);


);



But I cannot figure out how to resolve it. I use the script for suggesting queries while the user is typing. Why does it cause my updated value to disappear? I have tried moving around this and my first script for loading the previous query value, but nothing is working.










share|improve this question
























  • That looks like a weird way to do the autocomplete.... Been awhile since I used it, but should be using source with a function that does the ajax call....

    – epascarello
    Mar 7 at 17:41












  • Possible duplicate of Understanding and implementing jQuery autocomplete with AJAX source and appendTo

    – Louys Patrice Bessette
    Mar 7 at 18:03











  • What does jQuery load have to do with this?

    – Barmar
    Mar 7 at 18:31















0















So, I have a search bar on my site:



<form action="" method="GET" class="form-inline justify-content-center">
<input type="text" id="s_bar2" name="search" size = "75" class="form-control mr-sm-2" aria-label="Search">
<input class="btn btn-outline-primary my-2 my-sm-0" type="submit" value="Search">
</form>


And after a search is executed, I maintain the query in the bar by pulling it from the URL using this script:



 <script type="text/javascript">
var elem = document.getElementById("s_bar2");
const urlParams = new URLSearchParams(window.location.search);
elem.value = urlParams.get('search');
</script>


However, the previous query only appears in the search box for a few milliseconds before vanishing. I have pinpointed the issue to my script:



 $(document).ready(function() 
$("#s_bar2").autocomplete(
source: "/policy_suggest/"
);


);



But I cannot figure out how to resolve it. I use the script for suggesting queries while the user is typing. Why does it cause my updated value to disappear? I have tried moving around this and my first script for loading the previous query value, but nothing is working.










share|improve this question
























  • That looks like a weird way to do the autocomplete.... Been awhile since I used it, but should be using source with a function that does the ajax call....

    – epascarello
    Mar 7 at 17:41












  • Possible duplicate of Understanding and implementing jQuery autocomplete with AJAX source and appendTo

    – Louys Patrice Bessette
    Mar 7 at 18:03











  • What does jQuery load have to do with this?

    – Barmar
    Mar 7 at 18:31













0












0








0








So, I have a search bar on my site:



<form action="" method="GET" class="form-inline justify-content-center">
<input type="text" id="s_bar2" name="search" size = "75" class="form-control mr-sm-2" aria-label="Search">
<input class="btn btn-outline-primary my-2 my-sm-0" type="submit" value="Search">
</form>


And after a search is executed, I maintain the query in the bar by pulling it from the URL using this script:



 <script type="text/javascript">
var elem = document.getElementById("s_bar2");
const urlParams = new URLSearchParams(window.location.search);
elem.value = urlParams.get('search');
</script>


However, the previous query only appears in the search box for a few milliseconds before vanishing. I have pinpointed the issue to my script:



 $(document).ready(function() 
$("#s_bar2").autocomplete(
source: "/policy_suggest/"
);


);



But I cannot figure out how to resolve it. I use the script for suggesting queries while the user is typing. Why does it cause my updated value to disappear? I have tried moving around this and my first script for loading the previous query value, but nothing is working.










share|improve this question
















So, I have a search bar on my site:



<form action="" method="GET" class="form-inline justify-content-center">
<input type="text" id="s_bar2" name="search" size = "75" class="form-control mr-sm-2" aria-label="Search">
<input class="btn btn-outline-primary my-2 my-sm-0" type="submit" value="Search">
</form>


And after a search is executed, I maintain the query in the bar by pulling it from the URL using this script:



 <script type="text/javascript">
var elem = document.getElementById("s_bar2");
const urlParams = new URLSearchParams(window.location.search);
elem.value = urlParams.get('search');
</script>


However, the previous query only appears in the search box for a few milliseconds before vanishing. I have pinpointed the issue to my script:



 $(document).ready(function() 
$("#s_bar2").autocomplete(
source: "/policy_suggest/"
);


);



But I cannot figure out how to resolve it. I use the script for suggesting queries while the user is typing. Why does it cause my updated value to disappear? I have tried moving around this and my first script for loading the previous query value, but nothing is working.







javascript jquery html






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 11 at 14:47









Yevgen Gorbunkov

1,53031634




1,53031634










asked Mar 7 at 17:34









Noah OmdalNoah Omdal

113




113












  • That looks like a weird way to do the autocomplete.... Been awhile since I used it, but should be using source with a function that does the ajax call....

    – epascarello
    Mar 7 at 17:41












  • Possible duplicate of Understanding and implementing jQuery autocomplete with AJAX source and appendTo

    – Louys Patrice Bessette
    Mar 7 at 18:03











  • What does jQuery load have to do with this?

    – Barmar
    Mar 7 at 18:31

















  • That looks like a weird way to do the autocomplete.... Been awhile since I used it, but should be using source with a function that does the ajax call....

    – epascarello
    Mar 7 at 17:41












  • Possible duplicate of Understanding and implementing jQuery autocomplete with AJAX source and appendTo

    – Louys Patrice Bessette
    Mar 7 at 18:03











  • What does jQuery load have to do with this?

    – Barmar
    Mar 7 at 18:31
















That looks like a weird way to do the autocomplete.... Been awhile since I used it, but should be using source with a function that does the ajax call....

– epascarello
Mar 7 at 17:41






That looks like a weird way to do the autocomplete.... Been awhile since I used it, but should be using source with a function that does the ajax call....

– epascarello
Mar 7 at 17:41














Possible duplicate of Understanding and implementing jQuery autocomplete with AJAX source and appendTo

– Louys Patrice Bessette
Mar 7 at 18:03





Possible duplicate of Understanding and implementing jQuery autocomplete with AJAX source and appendTo

– Louys Patrice Bessette
Mar 7 at 18:03













What does jQuery load have to do with this?

– Barmar
Mar 7 at 18:31





What does jQuery load have to do with this?

– Barmar
Mar 7 at 18:31












1 Answer
1






active

oldest

votes


















0














I would get rid of most of your code as autocomplete has its own AJAX Function (https://jqueryui.com/autocomplete/) and use term instead of search in your server side code



 $(document).ready(function() 
$("#s_bar2").autocomplete(
source: "/policy_suggest/"
);
);





share|improve this answer























  • I updated the code with this, and the autocomplete is still working (thanks, smarter approach) but I still have the previous query only showing up in the new page's search bar for a few milliseconds before disappearing. Any ideas?

    – Noah Omdal
    Mar 7 at 22:19











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%2f55049779%2fwhy-does-jquery-script-make-values-loaded-in-input-object-to-disappear%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 would get rid of most of your code as autocomplete has its own AJAX Function (https://jqueryui.com/autocomplete/) and use term instead of search in your server side code



 $(document).ready(function() 
$("#s_bar2").autocomplete(
source: "/policy_suggest/"
);
);





share|improve this answer























  • I updated the code with this, and the autocomplete is still working (thanks, smarter approach) but I still have the previous query only showing up in the new page's search bar for a few milliseconds before disappearing. Any ideas?

    – Noah Omdal
    Mar 7 at 22:19















0














I would get rid of most of your code as autocomplete has its own AJAX Function (https://jqueryui.com/autocomplete/) and use term instead of search in your server side code



 $(document).ready(function() 
$("#s_bar2").autocomplete(
source: "/policy_suggest/"
);
);





share|improve this answer























  • I updated the code with this, and the autocomplete is still working (thanks, smarter approach) but I still have the previous query only showing up in the new page's search bar for a few milliseconds before disappearing. Any ideas?

    – Noah Omdal
    Mar 7 at 22:19













0












0








0







I would get rid of most of your code as autocomplete has its own AJAX Function (https://jqueryui.com/autocomplete/) and use term instead of search in your server side code



 $(document).ready(function() 
$("#s_bar2").autocomplete(
source: "/policy_suggest/"
);
);





share|improve this answer













I would get rid of most of your code as autocomplete has its own AJAX Function (https://jqueryui.com/autocomplete/) and use term instead of search in your server side code



 $(document).ready(function() 
$("#s_bar2").autocomplete(
source: "/policy_suggest/"
);
);






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 7 at 18:35









imvain2imvain2

2,7971512




2,7971512












  • I updated the code with this, and the autocomplete is still working (thanks, smarter approach) but I still have the previous query only showing up in the new page's search bar for a few milliseconds before disappearing. Any ideas?

    – Noah Omdal
    Mar 7 at 22:19

















  • I updated the code with this, and the autocomplete is still working (thanks, smarter approach) but I still have the previous query only showing up in the new page's search bar for a few milliseconds before disappearing. Any ideas?

    – Noah Omdal
    Mar 7 at 22:19
















I updated the code with this, and the autocomplete is still working (thanks, smarter approach) but I still have the previous query only showing up in the new page's search bar for a few milliseconds before disappearing. Any ideas?

– Noah Omdal
Mar 7 at 22:19





I updated the code with this, and the autocomplete is still working (thanks, smarter approach) but I still have the previous query only showing up in the new page's search bar for a few milliseconds before disappearing. Any ideas?

– Noah Omdal
Mar 7 at 22:19



















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%2f55049779%2fwhy-does-jquery-script-make-values-loaded-in-input-object-to-disappear%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

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович