1

I want to pass some textbox value strictly using POST from one html page to another... how can this be done without using any server side language like asp.net or php

can it be done using javascript??

thnx

1Mayur
  • 3,419
  • 5
  • 40
  • 64
  • Do you want to POST the form with javascript or read the POST data? – madflow Jun 05 '12 at 12:01
  • @madflow I want to first post the data from page1.html to page2.html then read/assign it there. – 1Mayur Jun 05 '12 at 12:03
  • @Sirwani POST request can only be accessed server-side. Use "GET". – madflow Jun 05 '12 at 12:05
  • @Sirwani using GET, you can read the url plus querystring using document.location. You would need to parse the text to pull out your values. – CM Kanode Jun 05 '12 at 12:07
  • @madflow thnx... that means it is not possible..?? hmm... – 1Mayur Jun 05 '12 at 12:07
  • @CMKanode using get we can but Q is using POST.. – 1Mayur Jun 05 '12 at 12:10
  • @Sirwani to the best of my knowledge, POST variables are unavailable to JavaScript on the client-side. – CM Kanode Jun 05 '12 at 12:14
  • @CMKanode thnx.. lets see what other have to say... I wish it could be possible :) – 1Mayur Jun 05 '12 at 12:17
  • @Sirwani I deleted my comment as it may seem offensive, I'm just saying your comment was rude for no reason. – Florian Margaine Jun 05 '12 at 12:21
  • @FlorianMargaine ... his very first comment on my q was not constructive and more over he is saying m lazy to code it on server side... boss.. i want to achieve it from client side.. thats what the q is and thats what is the challenge... first read it and then comment... his comment was rude first – 1Mayur Jun 05 '12 at 12:24

1 Answers1

5

You can't read POST data in any way on javascript so this is not doable.

Here you can find similar questions:

http://forums.devshed.com/javascript-development-115/read-post-data-in-javascript-1172.html

http://www.sitepoint.com/forums/showthread.php?454963-Getting-GET-or-POST-variables-using-JavaScript

This reading can also be interesting: http://en.wikipedia.org/wiki/POST_%28HTTP%29

This expecially suggests why this answer (wikipedia is the source):

GET Requests a representation of the specified resource. Requests using GET should only retrieve data and should have no other effect. (This is also true of some other HTTP methods.)[1] The W3C has published guidance principles on this distinction, saying, "Web application design should be informed by the above principles, but also by the relevant limitations."[10] See safe methods below.

POST Submits data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both.

POST data is added to the request. When you do a GET request the data is added to the url, and that's why you can access it through javascript (and that's why it's not parsed and you have to do it manually). Instead, POST send data directly into the http requests, which is not seen in any way by the html page (which is just a part of what is sent through the http request).

That said, only server side language will receive the full HTTP request, and definitely you can' access it by javascript.

I'm sorry but that is the real answer

Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147
  • 1
    [here's another one](http://stackoverflow.com/questions/1961069/getting-value-get-or-post-variable-using-javascript) – ClydeFrog Jun 05 '12 at 12:21
  • If that exists, I think we can mark the question as a duplicate. – Francesco Belladonna Jun 05 '12 at 12:25
  • 1
    This is quite an ambiguous question. HTTP is a client-server technology, so in principle, you can't POST to any page that is not on a server. – Christian Jun 05 '12 at 12:26
  • @Christian: Well, the question isn't amiguous. If you don't know the HTTP protocol you simply don't know you can't read POST data for reasons you explained. – Francesco Belladonna Jun 05 '12 at 12:28
  • @Fire-Dragon-DoL my intention was not JavaScript.. that was one of the things that can help.... the Q that ClydeFrog has listed is purely based on JavaScript – 1Mayur Jun 05 '12 at 12:29