I am building a custom theme and using wp_enqueue_scripts
to load a custom JS file for a specific page template. As you can see I declared jquery
as a dependency...
function enqueue_theme_scripts() {
if (is_page_template('template-contact.php')) {
wp_enqueue_script(
'template-contact-js',
get_bloginfo('template_directory') . '/template-contact.js',
array('jquery'),
false,
true
);
}
}
add_action('wp_enqueue_scripts', 'enqueue_theme_scripts');
This is what I have in the JS file...
(function($) {
$(document).ready(function() {
console.log($);
console.log($.ajax);
});
})(jQuery);
This is what the 'console' tab shows...
jQuery is loaded, but the $.ajax
method is not included.
This is what the 'sources' tab in the Inspector shows...
As you can see it is loading jQuery version 3.4.1, but line 48 seems to indicate that ajax is being removed. How do I get jquery to load with the ajax method included?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744704611a4588979.html
评论列表(0条)