By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,474 Members | 1,273 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,474 IT Pros & Developers. It's quick & easy.

Post data to server from javascript on client side

P: n/a
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.

Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
If you can stick with Mozilla support only, you could use JS Connect.
From what I remember, it allowed for direct connection between

JavaScript on a client to an app on the Server.

Personally I've never tried using JS Connect as I, unfortunately, must
support IE as the primary browser.
JsD
[Happily building IE deployed apps with Mozilla]

Jul 23 '05 #2

P: n/a
Do you really mean POST (as opposed to GET), or just "send".

To send values via a GET you could create an image in js and assign a
URL containing your (suitably encoded) values to its src.
Or use the (XML)HTTP request object (activex in IE and buil-in in NS
IIRC) to GET or POST.
http://jibbering.com/2002/4/httprequest.html
Or use remote scripting (google for this and you should find at least
one relatively cross-browser implementation).

Tim.

"milkyway" <d0******@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
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.

Jul 23 '05 #3

P: n/a

milkyway wrote:

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.


What prevents you from having a (named) form on your page with properly
setup action="http://yourhost.com/yourreceiving.cgi" in the tag. Then
populate the input field values manually or from JS and then use
yourformname.submit(); when you're done?
If you want the original page to stay on the same URL, you can just make
the form open a new window, which, when fully loaded, will close itself.
Gotta be careful with popups after the Win XP SP2 though - could easily be
disabled on the customer's PC. Can always submit the original page and
then redirect it back if popup is a problem.
Sincerely,
Dmitri
http://www.1-script.com/install/
Check out my CGI scripts installation offer
-------------------------------------


##-----------------------------------------------#
Article posted with Web Developer's USENET Archiv
http://www.1-script.com/forum
no-spam read and post WWW interface to your favorite newsgroup -
comp.lang.javascript,comp.infosystems.www.authoring.html - messages and counting
##-----------------------------------------------##
Jul 23 '05 #4

P: n/a
Hello again everybody,

Grant asked me to say what my goal is soooo here it goes (actually, I
thought I had posted it a short while ago but it does not look like my
new info made it out to the network).

Basically, I have a table on the HTML page that one can add rows to
dynamically. After rows are added, I want to save the contents of the
table to the server and eventually to be saved to a database. I have
found that by using the statements below, I am able to get the data out
of the cell:

myrow=mytablebody.getElementsByTagName("tr").item( row);
mycel=myrow.getElementsByTagName("td").item(column );
data=mycel.childNodes.item(0).data;

Now I just need to send it to the server. I was doing further search on
the net and saw that hidden fields can be used - but - how does one add
hidden fields (dynamically) to a form? Also, in addition to the "hidden
fields" solution, there is a one that uses a "query string" - at least
that is what they say on this page here:

http://forums.devshed.com/archive/t-16003

Which approach is better - hidden fields or query string and (as asked
above) if hidden fields are better, how does one add them dynamically
to a form?

Regards,
Milkyway

Jul 23 '05 #5

P: n/a
Hi once more,

Here is a link where one is adding the parameters to an action
attribute of a form.

Regards.

http://groups-beta.google.com/group/...11be38a6dfce90
milkyway wrote:
Hello again everybody,

Grant asked me to say what my goal is soooo here it goes (actually, I
thought I had posted it a short while ago but it does not look like my new info made it out to the network).

Basically, I have a table on the HTML page that one can add rows to
dynamically. After rows are added, I want to save the contents of the
table to the server and eventually to be saved to a database. I have
found that by using the statements below, I am able to get the data out of the cell:

myrow=mytablebody.getElementsByTagName("tr").item( row);
mycel=myrow.getElementsByTagName("td").item(column );
data=mycel.childNodes.item(0).data;

Now I just need to send it to the server. I was doing further search on the net and saw that hidden fields can be used - but - how does one add hidden fields (dynamically) to a form? Also, in addition to the "hidden fields" solution, there is a one that uses a "query string" - at least that is what they say on this page here:

http://forums.devshed.com/archive/t-16003

Which approach is better - hidden fields or query string and (as asked above) if hidden fields are better, how does one add them dynamically
to a form?

Regards,
Milkyway


Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.