使用会话ID jquery追加url

Dir*_*ign 3 jquery

我有一个静态会话ID我正在使用,需要在点击时将其添加到URL,但似乎无法正确使用它.如果您转到http://www.mysite.com/test.php进行重定向,则需要添加会话ID XYX,因此访问该页面的正确URL将是http://www.mysite.com/ test.php的?会话ID = XYX

<a href="http://www.mysite.com/test.php" class="foo">link here</a>

$('.foo').click(function(){
  (this).append(?sessionid=XYX');'
});
Run Code Online (Sandbox Code Playgroud)

我知道这是错的,我发现的所有文档都比我的需要复杂得多.谢谢!

Sco*_*ler 5

这应该添加会话ID并将用户发送到新url,使用e.preventDefault正常事件停止系统,然后将会话ID添加到url并在那里发送浏览器:

<a href="http://www.mysite.com/test.php" class="foo">link here</a>

$('.foo').click(function(e)
{
    e.preventDefault();
    window.location = $(this).attr('href') + '?sessionid=XYX';
});
Run Code Online (Sandbox Code Playgroud)