1

I have this function after an ajax post.

success: function(){

    window.location = 'morefive.php?document=' + path;
    }

I wanted to know how I could pass two variables, I have been having trouble figuring this out for jquery. It would be the equivalent of morefive.php?document=path&url=link the variable link being a url (would it have to be encoded?)

3
  • I'm not sure I understand - pass two variables to what? Pass two variables into the success event handler? I guess that depends on where you're getting path and link from. Commented Aug 7, 2011 at 2:45
  • im passing two variables to morefive.php......one is path (number) and one is link (string) Commented Aug 7, 2011 at 2:46
  • Yes, but where are you getting those values? You mention you're trying to figure this out with jQuery, but I don't see where jQuery plays a part in this. Are you trying to get the values passed into the success callback? Commented Aug 7, 2011 at 2:49

2 Answers 2

1

If i understand your question, you need to use encodeURIComponent() like this:

window.location = 'morefive.php?document=' + path + '&url=' + encodeURIComponent(link);
Sign up to request clarification or add additional context in comments.

2 Comments

agreed this is a good answer. but check out encodeUIRComponent doc if you can w3schools.com/jsref/jsref_encodeURIComponent.asp
edited with encodeURIComponent because it's better, as you said, thanks.
0
window.location = 'movefive.php?document=' + path + '&url=' + linkvar

Nothing says you can't concatenate multiple strings/variables together. Just separate each var=value pair with a & character.

2 Comments

is there a limit on how long the string (url) can be ?
Depends on the web server, but about 4000 characters total is okay.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.