Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

append url with a session id jquery

Tags:

jquery

I have a static session ID i'm using and need to add it to a url when clicked, but can't seem to get it right. If you go to http://www.mysite.com/test.php you get redirected, the session id XYX needs to be added, so the correct url to hit the page would be http://www.mysite.com/test.php?sessionid=XYX

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

$('.foo').click(function(){
  (this).append(?sessionid=XYX');'
});

I know this is wrong, all documentation Ive found is much more complex than my needs. thanks!

like image 402
Dirty Bird Design Avatar asked Mar 03 '26 12:03

Dirty Bird Design


1 Answers

This should add the session ID and send the user to the new url, use the e.preventDefault to stop the system using the normal event, then add the session id to the url and send the browser there:

<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';
});
like image 76
Scoobler Avatar answered Mar 06 '26 03:03

Scoobler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!