Cannot add javascript to footerTurn jQuery.ajax() request into XMLHttpRequest (vanilla JavaScript)Using a...

Why didn't Thatcher give Hong Kong to Taiwan?

How can an F-22 Raptor reach supersonic speeds without having supersonic inlets?

Single vs Multiple Try Catch

What is the maximal acceptable delay between pilot's input and flight control surface actuation?

German equivalent to "going down the rabbit hole"

Why wasn't Linda Hamilton in T3?

How do you manage to study and have a balance in your life at the same time?

garage light with two hots and one neutral

An alternative to "two column" geometry proofs

How secure are public hashed passwords (with a salt)?

How can I modify a line which contains 2nd occurence of a string?

How does the search space affect the speed of an ILP solver?

What is the definition of Product

Why do we need explainable AI?

What are the electrical characteristics of a PC gameport?

Colored grid with coordinates on all sides?

Can authors email you PDFs of their textbook for free?

If the government illegally doesn't ask for article 50 extension, can parliament do it instead?

How were US credit cards verified in-store in the 1980's?

Different past tense for various *et words

Heuristic argument for the Riemann Hypothesis

Are there balance issues when allowing attack of opportunity against any creature?

What is the motivation behind designing a control stick that does not move?

How to have the "Restore Missing Files" function from Nautilus without installing Nautilus?



Cannot add javascript to footer


Turn jQuery.ajax() request into XMLHttpRequest (vanilla JavaScript)Using a loop to build and update widgetsDynamic form variables for post metaPush metadata in arrayIs it save to use eval for a jQuery callback method coming from the database?Output array into one table cellCustom Post-Type not in admin menuAJAX in Wordpress, sending coords data to MySQL and show after into mapAdd Ajax Hooks and Call from Custom Template PHPJavascript / PHP - closing the loop






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







1















Im trying to paste my javascript into footer and cant figure out.



function js_enqueue_search(){
wp_register_script("search", get_stylesheet_directory_uri() . "/js/search.js", "", wp_get_theme()->get("Version"), true);
wp_localize_script('search', 'search_ajax', array("ajaxurl" =>admin_url("admin-ajax.php")));
}
add_action("wp_enqueue_scripts", "js_enqueue_search");









share|improve this question







New contributor



mckvak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















  • Is this code in your theme's functions.php file? Check your browser's dev tools. Are you getting a 404 on search.js?

    – Dave Romsey
    8 hours ago











  • @DaveRomsey Hello, its in functions.php I'm not even getting 404. It isnt showing at all.

    – mckvak
    8 hours ago






  • 1





    Woops ok, I missed this on the first read. Your're missing the call to wp_enqueue_script( 'search'); after it's registered.

    – Dave Romsey
    8 hours ago








  • 1





    @DaveRomsey Thanks a lot. :]

    – mckvak
    8 hours ago


















1















Im trying to paste my javascript into footer and cant figure out.



function js_enqueue_search(){
wp_register_script("search", get_stylesheet_directory_uri() . "/js/search.js", "", wp_get_theme()->get("Version"), true);
wp_localize_script('search', 'search_ajax', array("ajaxurl" =>admin_url("admin-ajax.php")));
}
add_action("wp_enqueue_scripts", "js_enqueue_search");









share|improve this question







New contributor



mckvak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















  • Is this code in your theme's functions.php file? Check your browser's dev tools. Are you getting a 404 on search.js?

    – Dave Romsey
    8 hours ago











  • @DaveRomsey Hello, its in functions.php I'm not even getting 404. It isnt showing at all.

    – mckvak
    8 hours ago






  • 1





    Woops ok, I missed this on the first read. Your're missing the call to wp_enqueue_script( 'search'); after it's registered.

    – Dave Romsey
    8 hours ago








  • 1





    @DaveRomsey Thanks a lot. :]

    – mckvak
    8 hours ago














1












1








1








Im trying to paste my javascript into footer and cant figure out.



function js_enqueue_search(){
wp_register_script("search", get_stylesheet_directory_uri() . "/js/search.js", "", wp_get_theme()->get("Version"), true);
wp_localize_script('search', 'search_ajax', array("ajaxurl" =>admin_url("admin-ajax.php")));
}
add_action("wp_enqueue_scripts", "js_enqueue_search");









share|improve this question







New contributor



mckvak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











Im trying to paste my javascript into footer and cant figure out.



function js_enqueue_search(){
wp_register_script("search", get_stylesheet_directory_uri() . "/js/search.js", "", wp_get_theme()->get("Version"), true);
wp_localize_script('search', 'search_ajax', array("ajaxurl" =>admin_url("admin-ajax.php")));
}
add_action("wp_enqueue_scripts", "js_enqueue_search");






php






share|improve this question







New contributor



mckvak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question







New contributor



mckvak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question






New contributor



mckvak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 9 hours ago









mckvakmckvak

102 bronze badges




102 bronze badges




New contributor



mckvak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




mckvak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Is this code in your theme's functions.php file? Check your browser's dev tools. Are you getting a 404 on search.js?

    – Dave Romsey
    8 hours ago











  • @DaveRomsey Hello, its in functions.php I'm not even getting 404. It isnt showing at all.

    – mckvak
    8 hours ago






  • 1





    Woops ok, I missed this on the first read. Your're missing the call to wp_enqueue_script( 'search'); after it's registered.

    – Dave Romsey
    8 hours ago








  • 1





    @DaveRomsey Thanks a lot. :]

    – mckvak
    8 hours ago



















  • Is this code in your theme's functions.php file? Check your browser's dev tools. Are you getting a 404 on search.js?

    – Dave Romsey
    8 hours ago











  • @DaveRomsey Hello, its in functions.php I'm not even getting 404. It isnt showing at all.

    – mckvak
    8 hours ago






  • 1





    Woops ok, I missed this on the first read. Your're missing the call to wp_enqueue_script( 'search'); after it's registered.

    – Dave Romsey
    8 hours ago








  • 1





    @DaveRomsey Thanks a lot. :]

    – mckvak
    8 hours ago

















Is this code in your theme's functions.php file? Check your browser's dev tools. Are you getting a 404 on search.js?

– Dave Romsey
8 hours ago





Is this code in your theme's functions.php file? Check your browser's dev tools. Are you getting a 404 on search.js?

– Dave Romsey
8 hours ago













@DaveRomsey Hello, its in functions.php I'm not even getting 404. It isnt showing at all.

– mckvak
8 hours ago





@DaveRomsey Hello, its in functions.php I'm not even getting 404. It isnt showing at all.

– mckvak
8 hours ago




1




1





Woops ok, I missed this on the first read. Your're missing the call to wp_enqueue_script( 'search'); after it's registered.

– Dave Romsey
8 hours ago







Woops ok, I missed this on the first read. Your're missing the call to wp_enqueue_script( 'search'); after it's registered.

– Dave Romsey
8 hours ago






1




1





@DaveRomsey Thanks a lot. :]

– mckvak
8 hours ago





@DaveRomsey Thanks a lot. :]

– mckvak
8 hours ago










1 Answer
1






active

oldest

votes


















1















Your're missing the call to wp_enqueue_script( 'search' ); after it's registered.



function js_enqueue_search() {
wp_register_script( 'search', get_stylesheet_directory_uri() . '/js/search.js', '', wp_get_theme()->get( 'Version' ), true );
wp_enqueue_script( 'search' );
wp_localize_script('search', 'search_ajax', array( 'ajaxurl' =>admin_url( 'admin-ajax.php' )));
}
add_action( 'wp_enqueue_scripts', 'js_enqueue_search' );





share|improve this answer


























  • Can I have one more Q please? I'm getting 404 with the AJAX request and can't find out. I got only this code and this JS. :: let ajax = new XMLHttpRequest(); ajax.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.ajax); } }; ajax.open("GET", search_ajax.nonceurl, true); ajax.send();

    – mckvak
    8 hours ago













  • This answer might be helpful: wordpress.stackexchange.com/a/301736/2807 If not, please create a new question for that issue.

    – Dave Romsey
    7 hours ago














Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "110"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});


}
});






mckvak is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f346379%2fcannot-add-javascript-to-footer%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









1















Your're missing the call to wp_enqueue_script( 'search' ); after it's registered.



function js_enqueue_search() {
wp_register_script( 'search', get_stylesheet_directory_uri() . '/js/search.js', '', wp_get_theme()->get( 'Version' ), true );
wp_enqueue_script( 'search' );
wp_localize_script('search', 'search_ajax', array( 'ajaxurl' =>admin_url( 'admin-ajax.php' )));
}
add_action( 'wp_enqueue_scripts', 'js_enqueue_search' );





share|improve this answer


























  • Can I have one more Q please? I'm getting 404 with the AJAX request and can't find out. I got only this code and this JS. :: let ajax = new XMLHttpRequest(); ajax.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.ajax); } }; ajax.open("GET", search_ajax.nonceurl, true); ajax.send();

    – mckvak
    8 hours ago













  • This answer might be helpful: wordpress.stackexchange.com/a/301736/2807 If not, please create a new question for that issue.

    – Dave Romsey
    7 hours ago
















1















Your're missing the call to wp_enqueue_script( 'search' ); after it's registered.



function js_enqueue_search() {
wp_register_script( 'search', get_stylesheet_directory_uri() . '/js/search.js', '', wp_get_theme()->get( 'Version' ), true );
wp_enqueue_script( 'search' );
wp_localize_script('search', 'search_ajax', array( 'ajaxurl' =>admin_url( 'admin-ajax.php' )));
}
add_action( 'wp_enqueue_scripts', 'js_enqueue_search' );





share|improve this answer


























  • Can I have one more Q please? I'm getting 404 with the AJAX request and can't find out. I got only this code and this JS. :: let ajax = new XMLHttpRequest(); ajax.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.ajax); } }; ajax.open("GET", search_ajax.nonceurl, true); ajax.send();

    – mckvak
    8 hours ago













  • This answer might be helpful: wordpress.stackexchange.com/a/301736/2807 If not, please create a new question for that issue.

    – Dave Romsey
    7 hours ago














1














1










1









Your're missing the call to wp_enqueue_script( 'search' ); after it's registered.



function js_enqueue_search() {
wp_register_script( 'search', get_stylesheet_directory_uri() . '/js/search.js', '', wp_get_theme()->get( 'Version' ), true );
wp_enqueue_script( 'search' );
wp_localize_script('search', 'search_ajax', array( 'ajaxurl' =>admin_url( 'admin-ajax.php' )));
}
add_action( 'wp_enqueue_scripts', 'js_enqueue_search' );





share|improve this answer













Your're missing the call to wp_enqueue_script( 'search' ); after it's registered.



function js_enqueue_search() {
wp_register_script( 'search', get_stylesheet_directory_uri() . '/js/search.js', '', wp_get_theme()->get( 'Version' ), true );
wp_enqueue_script( 'search' );
wp_localize_script('search', 'search_ajax', array( 'ajaxurl' =>admin_url( 'admin-ajax.php' )));
}
add_action( 'wp_enqueue_scripts', 'js_enqueue_search' );






share|improve this answer












share|improve this answer



share|improve this answer










answered 8 hours ago









Dave RomseyDave Romsey

13.5k8 gold badges41 silver badges57 bronze badges




13.5k8 gold badges41 silver badges57 bronze badges
















  • Can I have one more Q please? I'm getting 404 with the AJAX request and can't find out. I got only this code and this JS. :: let ajax = new XMLHttpRequest(); ajax.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.ajax); } }; ajax.open("GET", search_ajax.nonceurl, true); ajax.send();

    – mckvak
    8 hours ago













  • This answer might be helpful: wordpress.stackexchange.com/a/301736/2807 If not, please create a new question for that issue.

    – Dave Romsey
    7 hours ago



















  • Can I have one more Q please? I'm getting 404 with the AJAX request and can't find out. I got only this code and this JS. :: let ajax = new XMLHttpRequest(); ajax.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.ajax); } }; ajax.open("GET", search_ajax.nonceurl, true); ajax.send();

    – mckvak
    8 hours ago













  • This answer might be helpful: wordpress.stackexchange.com/a/301736/2807 If not, please create a new question for that issue.

    – Dave Romsey
    7 hours ago

















Can I have one more Q please? I'm getting 404 with the AJAX request and can't find out. I got only this code and this JS. :: let ajax = new XMLHttpRequest(); ajax.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.ajax); } }; ajax.open("GET", search_ajax.nonceurl, true); ajax.send();

– mckvak
8 hours ago







Can I have one more Q please? I'm getting 404 with the AJAX request and can't find out. I got only this code and this JS. :: let ajax = new XMLHttpRequest(); ajax.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.ajax); } }; ajax.open("GET", search_ajax.nonceurl, true); ajax.send();

– mckvak
8 hours ago















This answer might be helpful: wordpress.stackexchange.com/a/301736/2807 If not, please create a new question for that issue.

– Dave Romsey
7 hours ago





This answer might be helpful: wordpress.stackexchange.com/a/301736/2807 If not, please create a new question for that issue.

– Dave Romsey
7 hours ago










mckvak is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















mckvak is a new contributor. Be nice, and check out our Code of Conduct.













mckvak is a new contributor. Be nice, and check out our Code of Conduct.












mckvak is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to WordPress Development Stack Exchange!


  • 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%2fwordpress.stackexchange.com%2fquestions%2f346379%2fcannot-add-javascript-to-footer%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

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m