AJAX question
AJAX question
Trying to do something with AJAX--and failing. Any help welcome.
I have a bunch of pages (page-1.php, page-2.php, etc.) that all share a navigation menu (menu.html), which menu is included in the pages server side. The pages all use jQuery and (obviously) PHP, but the menu is (at the moment) straight HTML. Now I need to add to the menu an item (menu-item.php) that is fetched by AJAX, with which I have precious little experience (in JQuery or anywhere else).
I figured I could just add it to menu.html as follows:
- <ul>
- <li><a href="...">Menu Item 1</a></li>
- <li><a href="...">Menu Item 2</a></li>
- <script type="text/javascript">
- <!--
- $.get("menu-item.php");
- //-->
- </script>
- </ul>
But this doesn't work. The JS of course shows up in the page source, as viewed in FF, but it never fetches menu-item.php. What am I doing wrong?
P.S. The reason I want to use AJAX for this is that menu-item.php returns different content depending on the user's IP. And the reason I want to put it in menu.html is to avoid editing all the pages individually.