简体   繁体   中英

datepicker doesnt work as php include

I have a reservations booking bar that uses jquery datepicker from a small calendar button. When I go to the direct url of the php page, everything works fine. When I place the reservations booking bar as a php include on my wordpress theme's header.php file, the calendar button function doesn't work.

Main Site
http://192.185.167.175/~laurente/belle/

Reservations bar page
http://192.185.167.175/~laurente/belle/rez/phpinclude.php

Is there something I am missing?

You have 2 path errors on you site

Failed to load resource: the server responded with a status of 404 (Not Found) http://192.185.167.175/~laurente/belle/rez/js/jquery-1.10.2.custom.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://192.185.167.175/~laurente/belle/js/jquery-1.10.2.js
Uncaught TypeError: Property '$' of object [object Object] is not a function 

its seems as though the paths to the JS files are not correct namely these two

http://192.185.167.175/~laurente/belle/rez/js/jquery-1.10.2.custom.js
http://192.185.167.175/~laurente/belle/js/jquery-1.10.2.js

You shouldn't just include a PHP file into a WordPress page. You should ideally split up the stuff that should go into the header and the stuff that should go into the body.

That said, I think your main problem is loading jQuery twice (once in WordPress header, once in your PHP include). So if you cut out the line <script type="text/javascript" src="js/jquery-1.10.2.js"></script> from your PHP file and one of the jQuery UI includes, you may find it works.

For rapid testing purposes, you may find it useful to create another PHP file that has the JS links and includes the phpinclude.php - that way you have a common phpinclude.php that can be accessed in and out of WordPress.

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