call url while keep form parameters

G

Goldwind

Hi,

I"m writing a page in asp. When the user presses on Submit the form is
passed by Post to a url in a different site.
The problem is that i want to do this action in script, meaning call a
function which will call the url and pass the form by Post.

There are :
Server.Transfer - passes only to a page in the same site, so no good for me.
Response.Redirect - Doesnt pass and form or query parameters so no good for
me again :(

So how will i do this?

Thanks in advance
 
P

Paxton

Goldwind said:
Hi,

I"m writing a page in asp. When the user presses on Submit the form is
passed by Post to a url in a different site.
The problem is that i want to do this action in script, meaning call a
function which will call the url and pass the form by Post.

There are :
Server.Transfer - passes only to a page in the same site, so no good for me.
Response.Redirect - Doesnt pass and form or query parameters so no good for
me again :(

So how will i do this?

Thanks in advance

Why can't you simply apply the URL to the form's action attribute?

/P.
 
G

Goldwind

I want to do 2 operations on submit:
1. call a url (not on my server)
2. send an email.

If i will put the url on the action attrubute of the form then it will do 1
but not 2.
 
B

Bob Barrows [MVP]

Goldwind said:
I want to do 2 operations on submit:
1. call a url (not on my server)
2. send an email.

Submit to a page that first sends the email, and then redirects (using
Response.Redirect) to the remote page.
 
G

Goldwind

The problem is that "Response.Redirect" doesnt keep the form and query
parameters so the destination page will not be able to read them.
 
B

Bob Barrows [MVP]

Bob said:
Submit to a page that first sends the email, and then redirects (using
Response.Redirect) to the remote page.
Oops, I skipped to this reply without reading the OP - sorry.

I think you are going to need to use client-side code to accomplish this in
the form's onsubmit event. Use the xmlhttprequest object to submit your data
to the page that sends the email prior to submitting to the url on the
remote server.

See a client-side scripting newsgroup such as
microsoft.public.scripting.jscript for details. (Google should give you many
examples of using XMLHTTP)
 
B

Bob Barrows [MVP]

Goldwind said:
The problem is that "Response.Redirect" doesnt keep the form and query
parameters so the destination page will not be able to read them.
Well, it would be simple enough to add the passed form and querystring
values to the url in the Redirect statement, but then you would be subject
to the limitations imposed on what can be passed via querystring (there's a
size limit on the url as well).

See my followup to my original reply.
 
P

Paxton

Goldwind said:
The problem is that "Response.Redirect" doesnt keep the form and query
parameters so the destination page will not be able to read them.

So you want the Form data available to two separate pages? If that's
the case, it would suggest you want to do some processing on them
twice. Why can't you put all the processing code in one page?

If my assumption's wrong, can you tell us a bit more about what you are
trying to achieve?

/P.
 
K

Kyle Peterson

One option is to post to the page on your server and send the email.

Then use the xml parser component (available on most servers by default XP
Pro,2000,2003 at least)
to do a http post to the other server repopulating all your form data.

You basically dynamically build a suitable questring (the example below is
hardcoded) and then it actually passes each value as individual form
elements.


DataToSend = "id=1@name=pete@color=red"
dim xmlhttp
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST","http://localhost/Receiver.asp",false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send DataToSend
Set xmlhttp = nothing

Here is a page with a olot of good information on using this object.
http://www.perfectxml.com/MSXMLHTTP.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top