Is it possible to send something to the server without submit?

T

Tom Szabo

Hi,
I am wondering if it is possible to send/ submit something to a server and
not to update the page.

Considering a large page, when the user clicks on an item, I like to send a
message to the server but not change the page, so the large amount of code
doesn't have to be retransmitted back to the browser but the database would
be updated.

Is this possible at all?

TIA,

Tom
 
H

Hal Rosser

I am wondering if it is possible to send/ submit something to a server and
not to update the page.

Considering a large page, when the user clicks on an item, I like to send a
message to the server but not change the page, so the large amount of code
doesn't have to be retransmitted back to the browser but the database would
be updated.

make the server send a small page back to the browser with a script on it
that uses the history object of the browser so the 'small' response page
will call the previous page from the browser.
 
R

Randy Webb

Tom said:
Hi,
I am wondering if it is possible to send/ submit something to a server and
not to update the page.

Considering a large page, when the user clicks on an item, I like to send a
message to the server but not change the page, so the large amount of code
doesn't have to be retransmitted back to the browser but the database would
be updated.

Is this possible at all?

Use a hidden image and change its src attribute:

<img src="blank.gif" height="1" width="1" name="myImage">

document.images['myImage'].src =
"http://www.domain.com/someFile.php?parameters";

When someFile.php gets the call, it will execute without having to
reload the page.
 
T

Tom Szabo

Thanks very much,

Tom


Randy Webb said:
Tom said:
Hi,
I am wondering if it is possible to send/ submit something to a server and
not to update the page.

Considering a large page, when the user clicks on an item, I like to send a
message to the server but not change the page, so the large amount of code
doesn't have to be retransmitted back to the browser but the database would
be updated.

Is this possible at all?

Use a hidden image and change its src attribute:

<img src="blank.gif" height="1" width="1" name="myImage">

document.images['myImage'].src =
"http://www.domain.com/someFile.php?parameters";

When someFile.php gets the call, it will execute without having to
reload the page.
 
V

VK

It takes way out of JavaScript, but in HTTP protocol there are special
response code for such cases: "204 No Content".
If your server-side script sends such response (just header, no body),
browser stays still on the current page.

A dusty Perl sample:

if (submission_ok) {
print "HTTP/1.0 204 No Content\n\n";
}
else {
print &error_page;
}
 
T

Tom Szabo

Thanks very much, I though there should be something like that but had no
idea where to look for,

Thanks again,

Tom
 
G

Grant Wagner

Randy said:
Tom said:
Hi,
I am wondering if it is possible to send/ submit something to a server and
not to update the page.

Considering a large page, when the user clicks on an item, I like to send a
message to the server but not change the page, so the large amount of code
doesn't have to be retransmitted back to the browser but the database would
be updated.

Is this possible at all?

Use a hidden image and change its src attribute:

<img src="blank.gif" height="1" width="1" name="myImage">

document.images['myImage'].src =
"http://www.domain.com/someFile.php?parameters";

When someFile.php gets the call, it will execute without having to
reload the page.

I'm just curious why you do this with an actual <img> tag on the page.

(new Image()).src = "http://www.domain.com/someFile.php?parameters";

or

var img = new Image();
img.src = ...;

does the same thing, and does not require any supporting HTML.
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top