AJAX GET请求更改引用者

时间:2012-01-03 09:38:05

标签: javascript jquery get http-referer

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

但在我的情况下,用户被重定向到AJAX获取请求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&start=1&numResults=10&

而不是实际页面。

知道这里有什么问题吗?我已经检查了HTTPFOX,但Referer是正确的。它是实际的URL,但不是ajax url

2 个答案:

答案 0 :(得分: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);
        }
    });
});

答案 1 :(得分:0)

我已经尝试过很多东西,但最后更改了服务器端代码并​​将返回的url作为参数传递。

相关问题