我对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 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-07
Eelke