Unespected case

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Unespected case

Diego La Monica
Hi to all,
   in the paragraph 1.1 Example of Usage[1], preciselly in the example #2, you made this call:
client.open("POST", "/ping");
I suppose that this call cannot works fine. Maybe that on the web server root there is a page named simplly "ping", actually if you made the above call the response is processed correctly [2] .
I think that, for a back-compatiblity, you need to provide a different mode to make a ping call on the server.
Or I misunderstand the meaning of the example?

Best regards!

[1] <a href="http://www.w3.org/TR/2007/WD-XMLHttpRequest-20070227/#examples" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/TR/2007/WD-XMLHttpRequest-20070227/#examples
[2] http://www.dlamonica.netsons.org/test/ping.htm

--
Diego La Monica
Analista programmatore
Programmazione, Standards ed Accessibilità
Membro: IWA Italy
Via Napoli, 5 - Loc. la Scala
56028 San Miniato (PISA)

tel. (+39) 0571464992
cell. (+39) 3337235382
e-mail: [hidden email]
skype: diego.la.monica
ICQ #: 249-460-264
web: <a href="http://dlamonica.netsons.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://dlamonica.netsons.org
Reply | Threaded
Open this post in threaded view
|

Re: Unespected case

denis sureau
> client.open("POST", "/ping");

> I suppose that this call cannot works fine. Maybe that on the web server
> root there is a page named simplly "ping", actually if you made the above
> call the response is processed correctly [2] .
> I think that, for a back-compatiblity, you need to provide a different mode
> to make a ping call on the server.
> Or I misunderstand the meaning of the example?


The ping example seems not the best example of what a POST request usually is.
I suggest a more useful request as following, instead:

var xhr = new XMLHttpRequest();
xhr.onreadystatechange=function ()
{
if(xhr.readyState == 4)
{
alert("sent " + data);
}
};

xhr.open("POST", "test.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("data=" + data);


Denis Sureau - [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Unespected case

Diego La Monica
In reply to this post by Diego La Monica

Denis Sureau:

The ping example seems not the best example of what a POST request usually is.
I suggest a more useful request as following, instead:

var xhr = new XMLHttpRequest();
xhr.onreadystatechange=function()
{
if(xhr.readyState == 4)
{
alert("sent " + data);
}
};

xhr.open("POST", "test.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("data=" + data);


Denis Sureau - [hidden email]

Diego La Monica:
What you write is completelly right Mr. Sureau, but in example 2 of
paragraph 1.1 the working draft cites exactly:
***
If you just want to ping the server with a message you could do something like:

function ping(message) {
 var client = new XMLHttpRequest();
 client.open("POST", "/ping");
 client.send(message);
}
***
The above script is intended ( I suppose) as a System command but
maybe i'm in wrong and is a simple POST message that does not wait for
a respnse. In this case the word ping is not the right one is better
(IMHO): "If you just  want to make stay-up request to the server you
could do something like: .... ".

Dont you think so?


--
Diego La Monica
Analista programmatore
Programmazione, Standards ed Accessibilità
Membro: IWA Italy
Via Napoli, 5 - Loc. la Scala
56028 San Miniato (PISA)

tel. (+39) 0571464992
cell. (+39) 3337235382
e-mail: [hidden email]
skype: diego.la.monica
ICQ #: 249-460-264
web: http://dlamonica.netsons.org

Reply | Threaded
Open this post in threaded view
|

Re: Unespected case

Charles McCathieNevile-2

On Wed, 07 Mar 2007 19:07:51 +1100, Diego La Monica <[hidden email]> wrote:

>
> Denis Sureau:
>
> The ping example seems not the best example of what a POST request usually is.
> I suggest a more useful request as following, instead:
>
> var xhr = new XMLHttpRequest();
> xhr.onreadystatechange=function()
> {
> if(xhr.readyState == 4)
> {
> alert("sent " + data);
> }
> };
>
> xhr.open("POST", "test.php", true);
> xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
> xhr.send("data=" + data);
>
>
> Denis Sureau - [hidden email]
>
> Diego La Monica:
> What you write is completelly right Mr. Sureau, but in example 2 of
> paragraph 1.1 the working draft cites exactly:
> ***
> If you just want to ping the server with a message you could do something like:
>
> function ping(message) {
>  var client = new XMLHttpRequest();
>  client.open("POST", "/ping");
>  client.send(message);
> }
> ***
> The above script is intended ( I suppose) as a System command but
> maybe i'm in wrong and is a simple POST message that does not wait for
> a respnse. In this case the word ping is not the right one is better
> (IMHO): "If you just  want to make stay-up request to the server you
> could do something like: .... ".
>
> Dont you think so?

I think that using the word "ping" is a bad choice, since people who are used to programmin expect it to be related to the ping command, rather than just some local function for keep-alive or similar.

It seems to me that everybody is arguing that the example should do the same thing, and the wording is causing the confusion...

Cheers

Chaals

--
  Charles McCathieNevile, Opera Software: Standards Group
  hablo español  -  je parle français  -  jeg lærer norsk
[hidden email]          Try Opera 9.1     http://opera.com

Reply | Threaded
Open this post in threaded view
|

Re: Unespected case

Anne van Kesteren-2
In reply to this post by Diego La Monica

Hi,

On Thu, 01 Mar 2007 09:26:05 +0100, Diego La Monica <[hidden email]>  
wrote:
> client.open("POST", "/ping");

I changed this example:

   http://dev.w3.org/cvsweb/~checkout~/2006/webapi/XMLHttpRequest/Overview.html?content-type=text/html;%20charset=utf-8#examples

Cheers,


--
Anne van Kesteren
<http://annevankesteren.nl/>
<http://www.opera.com/>