reading post data in javascript
I suppose I could be lame, but can anyone point to an example or post a short one on how to read post data with javascript?
Thanks a mill,
sharyn
I suppose I could be lame, but can anyone point to an example or post a short one on how to read post data with javascript?
Thanks a mill,
sharyn
Abhishek Reddy posted this at 02:35 — 22nd December 2004.
He has: 3,348 posts
Joined: Jul 2001
I'm not sure if Javascript has access to POST variables directly. I remember writing one script where I had to integrate ASP to be able to get POST vars.
Do you have access to a server-side language? If you do, grab the POST vars with it and print out a Javascript:
<script type="text/javascript">
var myPostedVar = "<?php print $_POST['myvar'] ?>";
</script>
You could also expand this with a loop through all the POST vars, transferring data to Javascript variables...
Dragon of Ice posted this at 02:55 — 22nd December 2004.
He has: 578 posts
Joined: Jun 2004
I too am interested in this, as I the server that I'm developing for host nothing but client side regular stuff (like css, html, javascript), and the only easy way I can think of doing a print page is with switching style sheets, and I don't know how without php.
Abhishek Reddy posted this at 04:12 — 22nd December 2004.
He has: 3,348 posts
Joined: Jul 2001
I honestly can't recall being able to do this. Googling doesn't turn up much either.
I've kept persistent data with Javascript using server-side scripting, or frames, or storing strings in various objects. I wouldn't rely purely on client-side scripting for critical tasks.
In fact, why do you need to access POST data with Javascript anyway? If only JS is going to see the data (it's not being saved), why not use the GET method?
sharyn posted this at 19:49 — 22nd December 2004.
They have: 18 posts
Joined: Aug 2004
Abhisheck Reddy,
I don't want anyone to be able to insert a different userid into the url.
Dragon of Ice,
Lots of people say it can't be done, but one person has said it can be...I am waiting for that person to share his/her answer and as soon as I have it, I will share it with you.
CptAwesome posted this at 23:56 — 27th December 2004.
He has: 370 posts
Joined: Dec 2004
http://forums.devshed.com/archive/t-179178
says it can't be done. I don't know if Javascript even really supports the GET method, from what I have seen it's supported by a hack around reading the URL and parsing the string. If you don't want users to be able to modify the the stuff, leave a cookie maybe?
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.