简体   繁体   中英

javascript worked on local server but not in live server

i am working on wordpress site right now... i load some js in local and in live....js load perfectly in both server but don't know why my js is not working in live server.... this is the list of js that i loaded in both server...

function underskeleton_scripts() {
wp_enqueue_script('underskeleton-datepicker',get_template_directory_uri().'/js/bootstrap-datepicker.js',array(),'1.0.4',true);
wp_enqueue_script('underskeleton-scripts',get_template_directory_uri().'/js/theme.min.js',array(),'1.0.0',true);
wp_enqueue_script('underskeleton-owl-carousel',get_template_directory_uri().'/js/common_scripts.min.js',array(),'1.0.1',true);
wp_enqueue_script('underskeleton-owl-carousel-min',get_template_directory_uri().'/js/common.js',array(),'1.0.3',true);
wp_enqueue_script('underskeleton-function',get_template_directory_uri().'/js/functions.js',array(),'1.0.2',true);
wp_enqueue_script('underskeleton-datepicker',get_template_directory_uri().'/js/bootstrap-datepicker.js',array(),'1.0.5',true);

if(is_singular()&&comments_open()&&get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
}
add_action('wp_enqueue_scripts','underskeleton_scripts');

all js files loaded perfectly but didnt work....

this is link of that page..... http://isyncevolution.com/project/wp/dentist/detail-page/

in this page there is calender but i can't see that as js isn't working

If you check your browser console you see that 3 of your scripts are looking for jQuery, but this is not loaded.

When using wp_enqueue_script you can pass an array of registered script handles as 3rd parameter, so in your case:

wp_enqueue_script('underskeleton-datepicker',get_template_directory_uri().'/js/bootstrap-datepicker.js',array( 'jquery' ),'1.0.4',true);

Here you can find a list of all the handlers available in WP: https://developer.wordpress.org/reference/functions/wp_enqueue_script/

You have not added jquery. enqueue jquery before datepicker.js or paste this line before you are enqueuing datepicker.js.

wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', false, '1.11.3');
    wp_enqueue_script('jquery');

You have not defined datepicker with your "calender" div that's why it is not showing there. add this line into your code and date picker will be visible. for checking purpose you can also add this in you dev console.

jQuery( "#calendar" ).datepicker();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM