From: FAQ server on
-----------------------------------------------------------------------
FAQ Topic - How do I run a server side script?
-----------------------------------------------------------------------

You trigger a server-side script by sending an HTTP request.
This can be acheived by setting the ` src ` of an ` img `,
` Image `, ` frame `, or ` iframe `,
or by using XHR.

An image will also
"swallow" the data sent back by the server, so that they will
not be visible anywhere.

var dummyImage = new Image();
dummyImage.src = "scriptURL.asp?param=" + varName;

Mozilla, Opera 7.6+, Safari 1.2+, and Windows IE 7
provide the ` XMLHttpRequest ` object
(Windows IE versions 5+, provides ActiveX to acheive an analagous
effect). ` XMLHttpRequest ` can send HTTP requests to
the server, and provides access the ` responseText ` or ` responseXML `
(when the response is XML), and HTTP header information.

http://jibbering.com/2002/4/httprequest.html

http://www.w3.org/TR/XMLHttpRequest/

http://developer.mozilla.org/en/XMLHttpRequest

http://msdn.microsoft.com/en-us/library/ms537505(VS.85).aspx


The complete comp.lang.javascript FAQ is at
http://jibbering.com/faq/

--

The sendings of these daily posts are proficiently hosted
by http://www.pair.com.

From: Jorge on
On Jan 8, 1:00 am, "FAQ server" <javascr...(a)dotinternet.be> wrote:
> XMLHttpRequest ` can send HTTP requests to
> the server (...)

I would like to propose ~ this:

XMLHttpRequest can send HTTP requests only to the same domain and port
from where current page came from (as seen in the current
location.host and location.port), and using the same protocol (the
current location.protocol).

In order to make a request to a different domain, you can use <img>,
<script>, <iframe>, <style>, etc. instead.

?
--
Jorge.
From: Jorge on
On Jan 8, 4:11 am, Jorge <jo...(a)jorgechamorro.com> wrote:
>
> In order to make a request to a different domain, you can use <img>,
> <script>, <iframe>, <style>, etc. instead.

Although neither <script> nor <style> are very advisable :-)
--
Jorge.
From: kangax on
On 1/7/10 10:11 PM, Jorge wrote:
> On Jan 8, 1:00 am, "FAQ server"<javascr...(a)dotinternet.be> wrote:
>> XMLHttpRequest ` can send HTTP requests to
>> the server (...)
>
> I would like to propose ~ this:
>
> XMLHttpRequest can send HTTP requests only to the same domain and port
> from where current page came from (as seen in the current
> location.host and location.port), and using the same protocol (the
> current location.protocol).

Not if environment supports Cross-Origin Resource Sharing standard
(currently draft � http://www.w3.org/TR/cors/), and all prerequisites
are met (e.g. server response' headers indicate request allowance).

Firefox 3.5+ does (https://developer.mozilla.org/En/HTTP_Access_Control).

[...]

--
kangax
From: kangax on
On 1/7/10 7:00 PM, FAQ server wrote:
> -----------------------------------------------------------------------
> FAQ Topic - How do I run a server side script?
> -----------------------------------------------------------------------
>
> You trigger a server-side script by sending an HTTP request.
> This can be acheived by setting the ` src ` of an ` img `,
> ` Image `, ` frame `, or ` iframe `,
> or by using XHR.
>
> An image will also
> "swallow" the data sent back by the server, so that they will
> not be visible anywhere.
>
> var dummyImage = new Image();
> dummyImage.src = "scriptURL.asp?param=" + varName;
>
> Mozilla, Opera 7.6+, Safari 1.2+, and Windows IE 7

Wouldn't it make sense to also mention that IE7 (and 8) only provide
`XMLHttpRequest` when corresponding feature is enabled in browser?

[...]

--
kangax