我對ajax非常陌生,並將它成功應用於Drupal站點。但我想知道,我怎樣才能得到一個頁面的URL,其中一部分內容是通過ajax加載的。這甚至有可能嗎? JSON對象是通過點擊來檢索的,那麼如何在檢索某個URL時使其工作? 我意識到這是一個非常廣泛的問題,任何幫助將不勝感激。 在此先感謝!如何獲取ajax頁面的網址?
我的JS是這樣的:
Drupal.behaviors.ajax_pages = function (context) {
$('a.categoryLink:not(.categoryLink-processed)', context).click(function() {
var updateProducts = function(data) {
// The data parameter is a JSON object. The films property is the list of films items that was returned from the server response to the ajax request.
if (data.films != undefined) {
$('.region-sidebar-second .section').hide().html(data.films).fadeIn();
}
if (data.more != undefined) {
$('#content .section').hide().html(data.more).fadeIn();
}
}
$.ajax({
type: 'POST',
url: this.href, // Which url should be handle the ajax request. This is the url defined in the <a> html tag
success: updateProducts, // The js function that will be called upon success request
dataType: 'json', //define the type of data that is going to get back from the server
data: 'js=1' //Pass a key/value pair
});
return false; // return false so the navigation stops here and not continue to the page in the link
}).addClass('categoryLink-processed');
}
記得在模塊中添加菜單處理程序。 – 2010-09-09 16:55:52