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

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐