为什么这个jQuery不能重定向到另一个域?

时间:2011-10-30 13:04:36

标签: jquery

http://phplist.xxmn.com/zen/index.php?main_page=index&cPath=231

js代码,在dress.js中:

$('#1d, #1a').click(function(event){

    event.preventDefault();

    $('#producListing').load(this.attr('href'));
});

大字体价格上涨和价格下降是我将点击的文字,我想在点击页面无法刷新的文字时制作。谢谢,

4 个答案:

答案 0 :(得分:1)

尝试

$('#1d, #1a').click(function(event){
    var myHref = $(this).attr('href');
    $('#producListing').load(myHref);
    return false;
});

答案 1 :(得分:0)

您需要将this包装在jQuery-izer中,$(this)

另请注意,没有#producListing,它是#productListing

它将网站的完整副本加载到div中,这可能不是您想要的 - 但我假设您正在测试。

答案 2 :(得分:0)

请参阅jquery load documentation上的其他说明:

  

由于浏览器安全限制,大多数“Ajax”请求都受same origin policy的约束;请求无法成功从其他域,子域或协议中检索数据。

如果是您的域名,请将href更改为/zen/index.php?main_page=index&cPath=231

答案 3 :(得分:0)

scessor,

我看到你已经修好了't'产品列表。

试试这个,

$('#1a,#1d').click(function(){
    $('#productListing').load(this);
    return false;
});

更好的是,只要您不确定可用的上下文,就在FireBug中放置一个断点。