2012-01-03 120 views
0

我正在使用jQuery GET请求来获取一些内容并将其显示在页面上。问题是该页面有一个登录按钮。它使用户登录屏幕,成功登录后用户被重定向到更早的页面。AJAX GET请求更改引用者

但在我的情况下,用户正在被重定向到AJAX get Request URL。

这是我用来发出AJAX请求的代码。

jQuery(document).ready(function() { 
    jQuery.get('/morerecentblogs.jspa?communityId=2004&start=1&numResults=10&', 
    function(data) { 
     jQuery('#recent-blogs').html(data) 
    } 
) 

在用户登录后是越来越重定向到

/morerecentblogs.jspa?communityId=2004 &开始= 1个& numResults = 10 &

而不是实际的页。

任何想法这里有什么问题吗?我检查过HTTPFOX,但Referer是正确的。这是实际的URL而不是一个AJAX网址

+2

你如何重定向?你可以在服务器端发布该代码和任何其他相关代码吗? – 2012-01-03 09:40:54

+0

更重要的是,只要doc准备好就添加get函数 – run 2012-01-03 09:48:14

回答

0
jQuery(function($) { // Simplyfied jQuery ready method 
    // $ is now jQuery and it's safe in this scope. 

    $.ajax({ // Using ajax method instead. 
     "url": "/morerecentblogs.jspa?communityId=2004&start=1&numResults=10", 
     "type": "GET", // Type GET/POST 
     "dataType": "html", //HTML/JSON/JSONP/XML 
     "success": function(response) { // Your success handler 
      $('#recent-blogs').html(response); 
     } 
    }); 
}); 
+0

AJAX调用是正确的。但问题在于它正在改变引用者。 – 2012-01-03 10:19:19

0

嗯,我已经试过很多东西,但最后改变了服务器端的代码,并通过了返回URL作为参数。