Help reading parameter values from a form POST using javascript

Posted on 2007-08-01
Last Modified: 2008-01-09
Is there a way, using javascript, to read paramete values from a form POST? I have a function that pulls parameter values from a form GET e.g...

function getTheParam(wut,qp,dflt){ dflt=(dflt==null)?'':dflt; try{r=unescape(wut.match(new RegExp(qp+"=+([^&;]*)"))[1]);}catch(qp){r=dflt;} return r; }

But I can't seem to find anything for reading them from a form POST. Note that this is not a PHP question. Just a basic HTML question

Question by:biglarrrr
    LVL 6

    Accepted Solution

    the post variables go in to the request. the server needs to deal with the form variables.  If the page/script that deals with the variables doesn't in some way put them in the page that gets returned to the client, then there is no way for the client side javascript to be able to read them.  You could change the action on the form using javascript and append ?var1=value1&var2=value2
    and that way your function above would work, if the action page doesn't redirect to another page.
    LVL 6

    Assisted Solution

    I don't think there is any real way to read POST variables through convential means. You could possibly look at transmitting your form through another method - with the XMLHttpRequest object, or by using a hidden frame/new window as an intermediary. You could use the XMLHttpRequest to generate a response from the server, if you need to do some form processing you could have the page returned to you (or an output page to redirect to - you could post variables back to the server after processing?). A frame or window would let you store the form variables somewhere while you redirected the page after processing. I'm not sure what you had in mind, so it depends on what you have available to you.

    Author Comment

    Thank you gjutras and SirCrofty. I appreciate the help. I think we're just going to change the process flow for this.


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
    This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now