views:

134

answers:

3

Just started with JQuery and I've managed to pass a parameter using POST, firebug confirms this:

Parameters
link    [email protected]
Source
link=test1%40test.com

I don't know how to access the link parameter from the receiving page using JQuery, it must be so simple but everything I've been searching through (jquery website, SO, etc) mentions everything but this.

Thanks, Alex

+1  A: 

Javascript can not access POST. Sorry. You'll have to use a server-side technology, or use GET attributes, if appropriate.

Matchu
Well, you can use javascript in server side and thus access POST, but that's not what was asked ;-)
jholster
A: 

Strictly speaking, javascript cannot access POST parameters. What you could do though is have your server side language write the value into the response so the client side script can access it. So on the server you might have

var postData = <?php echo $_POST['link']; ?>;

And then you would access it like any other variable.

Chris Thompson
Ew, no. Never, ever, ever let unfiltered content into your HTML, much less your Javascript - it just makes it far too easy. At least wrap it in `json_encode`, if this is the path you choose to take, to make sure that the string is properly escaped for Javascript.
Matchu
@Matchu it was a quick example, of course that's a horrible idea. It was simply meant to illustrate the point.
Chris Thompson
A: 

You can only use POST parameters in request, being sent from client (javascript) to server. It won't make sense in other direction – server returns a response, not POST parameters. That's the fundamental issue, not javascript itself.

jholster