473,800 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

POST values in Javascript

Two questions.

1) Is there a way i can determine the page was a POST or a GET w/o
checking the "?" in the url?

2) Is there a way i can get the POST variables using javascript?
(example: like in php $_POST["name"] would have info if the page was
return as a post with a name field.)

Jan 9 '07 #1
4 1706
Ryan Knopp wrote on 09 jan 2007 in comp.lang.javas cript:
Two questions.

1) Is there a way i can determine the page was a POST or a GET w/o
checking the "?" in the url?
There is no reason why a page with post content cannot have a "?" and even
querystring content in the url.
2) Is there a way i can get the POST variables using javascript?
Yes, but only with serverside javascript,
as the post content in the header is not sent to the client.

I think.
(example: like in php $_POST["name"] would have info if the page was
return as a post with a name field.)
What PHP does with POSTed content is not on topic in this NG.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 9 '07 #2
Evertjan. said the following on 1/9/2007 6:35 PM:
Ryan Knopp wrote on 09 jan 2007 in comp.lang.javas cript:
<snip>
>(example: like in php $_POST["name"] would have info if the page was
return as a post with a name field.)

What PHP does with POSTed content is not on topic in this NG.
And that isn't what was asked. It was being asked if client side JS has
any mechanism that is similar to any server side language where you have
access to POSTed variables. And whether client side JS has such a
feature *is* on topic here.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 10 '07 #3
Randy Webb wrote on 10 jan 2007 in comp.lang.javas cript:
Evertjan. said the following on 1/9/2007 6:35 PM:
>Ryan Knopp wrote on 09 jan 2007 in comp.lang.javas cript:

<snip>
>>(example: like in php $_POST["name"] would have info if the page was
return as a post with a name field.)

What PHP does with POSTed content is not on topic in this NG.

And that isn't what was asked. It was being asked if client side JS has
any mechanism that is similar to any server side language where you have
access to POSTed variables. And whether client side JS has such a
feature *is* on topic here.
true

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 10 '07 #4
Evertjan. wrote:
Ryan Knopp wrote on 09 jan 2007 in comp.lang.javas cript:
>2) Is there a way i can get the POST variables using javascript?

Yes, but only with serverside javascript,
as the post content in the header is not sent to the client.
I think.
It's true by definition. Posted content is part of a HTTP request from
browser to server. Server then returns a response for that request. An
application might be programmed to send posted data back to the
browser, but you can't do that in client-side javascript because the
javascript code itself is part of the response.

It's possible though to combine javascript and your favourite
serverside language to get posted data in a javascript variable when
the page is being generated, something like

print "<script>\n var postedata = '" + $_POST["name"] + "'\n</script>"
(beware of " \n \ etc)

--
Bart

Jan 10 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4261
by: TG | last post by:
Dear PHP Group, I have two forms that are used to collect user information. The first one takes user inputted values such as fullname, city, address etc. I want these values to display in the second form when it is called. Both forms are .htm files that call themselves when the submit button is press via the following command in each form: <form method="post" action="<?php $server?>">
8
5096
by: dmcconkey | last post by:
Hi folks, I have a client with four websites. Each site has a contact form that is identical. They all have "required" fields validated through a JavaScript onSubmit() function. Upon validation, post values go to a PHP processing page that adds values to a database and generates an email to someone in marketing. For three of these sites, we have no problem, but the fourth keeps sending in blank forms.
5
2486
by: milkyway | last post by:
Hello everyone, I have a few values and variables that I want to post to a server (without using a SUBMIT button). Is there a way to post data from within javascript - do sockets or connections have to be open for this to work? Any help, hints or advice is appreciated :-) Kindest Regards.
3
3263
by: iam247 | last post by:
Hi I have an asp page without any javascript. It posts the content of a form to another page, which reads the form fields using Request.Form. This is the form header: <form name=form method=post action=RegDetails.asp> I have tried to modify the form by adding javascript for password
6
3816
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many user get used to click "enter" key to submit a form. How can I use "enter" key to submit/postback in ASP.NET. Thank, Guoqi Zheng
23
14523
by: Bjorn | last post by:
Hi. Every time i post data in a form the contents are being checked for validity. When i click the back-button, all data is gone and i have to retype it. It's obvious that only a few or none of the visitors will retype it all so i'm asking: "how to preserve POST-data when clicking the back-button?" i've already tried to print post data as a value in a HTML tag but
5
2347
by: sklett | last post by:
I'm not real experienced with asp.net so this may be obvious. I've got a situation where some of my client side javascript is causing my posted form's controls to lose their values. In other words, I have a server control TextBox, I enter some text, my client side scripts do some stuff and in the Page_Load method after submitting the form the value for my TextBox is empty. If the javascipt doesn't run, the values are fine. I've looked...
3
1724
by: Mani | last post by:
Hi I am trying to post the values to the form. The form action is not done in html i.e not in form tag, it is done by javascript code using document.FORMNAME.action = "results.asp"; I think in that results.asp file, they are creating one xml file for the posted values and these xml file has been redirected to some other asp file. for ex, displayresults.asp to show the results.
1
2334
by: Ben Brown | last post by:
I'm having some problems.. I have some javascript generated input elements with dynamic names and values. ex: <input name = "t1Name" .../> <input name = "t2Name" .../> ..... <input name = "tnName".../>
1
4307
by: ll | last post by:
I'm currently working on a form which consists of a show and hide javascript. The toggle works fine, although when I click on submit, I would like the page to reload with the toggle (show/hide) div in the same state it was before being submitted. E.G. If the div was visible, I'd like for it to be visible upon return. Here's the script I'm currently using - thanks for any help, Louis --------------------------------------------
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10279
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9092
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.