I am trying to get an AJAX script working on my page (working with Drupal 7). The content of the page should be loaded when clicking my menu links, but the page shouldn't be refreshed (this will interfere with a different script in jQuery that animates the banner)
Here is the source code:
(function ($, Drupal) {
jQuery.error = console.error;
$("<link/>", {
rel: "stylesheet",
type: "text/css",
href: "../css/pages.css"
}).appendTo("head");
$(document).ready(function()
{
$('.menu-704,.menu-797,.menu-359,.menu-796').click(function()
{
$('#main').load('linktopage.html');
});
});
})(jQuery, Drupal);
Now, this does work, but I experience the following problems:
如果链接是主题页面,请尝试更改为$('#main')。load('linktopage.html #main')
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.