XMLHttpRequest

W

William

function saveText( scroll_list, t_area, listToBeUpdated ) {
var updated = new Option();
updated.value = t_area.value;
updated.text = t_area.text;
for(var i = 0; i < scroll_list.options.length; i++) {
if( scroll_list.options.selected ) {
scroll_list.options[scroll_list.selectedIndex].text = updated.value;
scroll_list.options[scroll_list.selectedIndex].value= updated.value;
break;
}
}
var confirmReq;
var url = "http://mkmxg00/cgi/confirmUpload.pl";
confirmReq = new ActiveXObject( "Microsoft.XMLHTTP" );
confirmReq.onreadystatechange = processReqChange;
confirmReq.open( "POST", url, true );
confirmReq.send( "" );

alert( url );
}
function processReqChange() {
alert( confirmReq.readyState );
if ( confirmReq.readyState == 4 ) {
if ( confirmReq.status == 200 ) {
// process the response if successful
alert( "passed!" );
}
}
else {
alert( confirmReq.readyState + ", " + confirmReq.status );
}
}

my question:
how do I check what content is being sent over to
http://mkmxg00/cgi/confirmUpload.pl

in the XMLHttpRequest?
 
T

Thomas 'PointedEars' Lahn

William said:
function saveText( scroll_list, t_area, listToBeUpdated ) {
var updated = new Option();
updated.value = t_area.value;
updated.text = t_area.text;

This is nonsense because you do not really use `updated' later.
for(var i = 0; i < scroll_list.options.length; i++) {
if( scroll_list.options.selected ) {
scroll_list.options[scroll_list.selectedIndex].text =
updated.value;


Assigning t_area.value is equivalent, however you probably wanted
to assign t_area.text. And are you really sure you want to make all
selected items the same?
scroll_list.options[scroll_list.selectedIndex].value=
updated.value;

Assigning t_area.value is equivalent.
[...]
confirmReq.open( "POST", url, true );
[...]
confirmReq.send( "" );
[...]
my question:
how do I check what content is being sent over to
http://mkmxg00/cgi/confirmUpload.pl
^^
Ask in a Perl or CGI-related newsgroup about how to process a (POST)
request.
in the XMLHttpRequest?

What you pass as the argument of confirmReq.send() becomes the body of the
request which is evaluated _server-side_. The IXMLHTTPRequest interface
which provides _client-side_ access to the _response_ of the request does
not provide a property to access the request body later.


PointedEars
 
W

William

William said:
function saveText( scroll_list, t_area, listToBeUpdated ) {
var updated = new Option();
updated.value = t_area.value;
updated.text = t_area.text;

This is nonsense because you do not really use `updated' later.
for(var i = 0; i < scroll_list.options.length; i++) {
if( scroll_list.options.selected ) {
scroll_list.options[scroll_list.selectedIndex].text =
updated.value;


Assigning t_area.value is equivalent, however you probably wanted
to assign t_area.text. And are you really sure you want to make all
selected items the same?
scroll_list.options[scroll_list.selectedIndex].value=
updated.value;

Assigning t_area.value is equivalent.
[...]
confirmReq.open( "POST", url, true );
[...]
confirmReq.send( "" );
[...]
my question:
how do I check what content is being sent over to
http://mkmxg00/cgi/confirmUpload.pl
^^
Ask in a Perl or CGI-related newsgroup about how to process a (POST)
request.
in the XMLHttpRequest?

What you pass as the argument of confirmReq.send() becomes the body of the
request which is evaluated _server-side_. The IXMLHTTPRequest interface
which provides _client-side_ access to the _response_ of the request does
not provide a property to access the request body later.


To make a long story short, I was asked by [another person, whose's
instructions I have to follow] to scrap my code with XMLHttpRequest and
possibly update the server text file with server side javascript.

The current process:
1) web browser displays values of server side text file thru the GUI
2) the user modifies the values in this text file thru the GUI
3) such modifications needs to be reflected on the server side text file.

Assuming I successfully embedded the server side javascript code which
updates the server side text file; how do I send an HTTP request for a 2nd
time (i.e. after the user has made the changes), so that my server side
javascript code actually updates the server side text file?

This is my first time writing server side javascript, any
suggestions/references is appreciated.

(I am currently reading up on:
http://docs.sun.com/source/816-6411-10/jsserv.htm#1024580)
 
T

Thomas 'PointedEars' Lahn

William said:
^^
Ask in a Perl or CGI-related newsgroup about how to process a (POST)
request.


What you pass as the argument of confirmReq.send() becomes the body of
the request which is evaluated _server-side_. The IXMLHTTPRequest
interface which provides _client-side_ access to the _response_ of the
request does not provide a property to access the request body later.

To make a long story short, I was asked by [another person, whose's
instructions I have to follow] to scrap my code with XMLHttpRequest and
possibly update the server text file with server side javascript.

In case you misunderstood me saying that (client-side) XMLHTTP requests are
a Bad Thing, that was not the case.

Are you saying that you now must implement a JS solution also server-side,
instead of a Perl solution?
The current process:
1) web browser displays values of server side text file thru the GUI
2) the user modifies the values in this text file thru the GUI
3) such modifications needs to be reflected on the server side text file.

Assuming I successfully embedded the server side javascript code which
updates the server side text file; how do I send an HTTP request for a 2nd
time (i.e. after the user has made the changes), so that my server side
javascript code actually updates the server side text file?

I am not sure that you understood the difference between client-side and
server-side code, and I am not sure if I understood you correctly. For
one, HTTP requests AIUI you need them to transmit user modifications from
the client to the server have to be initiated from the client, not from the
server. And since client-side script code does not change, no matter the
server-side code (unless the server-side code generates the sending
client-side one), you just send the same request with different data again.
The server always sends a response, not a request, to the client; this
response can of course include any data you want, including the changed
text file content. So you do not need another request just to show the
updated data, not matter the programming language used to create the
response.


PointedEars
 
R

Randy Webb

William said the following on 2/6/2006 11:27 AM:
To make a long story short, I was asked by [another person, whose's
instructions I have to follow] to scrap my code with XMLHttpRequest and
possibly update the server text file with server side javascript.

The current process:
1) web browser displays values of server side text file thru the GUI
2) the user modifies the values in this text file thru the GUI
3) such modifications needs to be reflected on the server side text file.

Place the contents of the text file in a textarea with a submit button.
Submit the form, let the server update as appropriate.
 
W

William

William said:
William wrote:
how do I check what content is being sent over to
http://mkmxg00/cgi/confirmUpload.pl
^^
Ask in a Perl or CGI-related newsgroup about how to process a (POST)
request.

in the XMLHttpRequest?

What you pass as the argument of confirmReq.send() becomes the body of
the request which is evaluated _server-side_. The IXMLHTTPRequest
interface which provides _client-side_ access to the _response_ of the
request does not provide a property to access the request body later.

To make a long story short, I was asked by [another person, whose's
instructions I have to follow] to scrap my code with XMLHttpRequest and
possibly update the server text file with server side javascript.

In case you misunderstood me saying that (client-side) XMLHTTP requests are
a Bad Thing, that was not the case.

Are you saying that you now must implement a JS solution also server-side,
instead of a Perl solution?

I was taking over somebody else's Perl script, and within the Perl script
also contains javascript code.
I am not sure that you understood the difference between client-side and
server-side code, and I am not sure if I understood you correctly. For
one, HTTP requests AIUI you need them to transmit user modifications from
the client to the server have to be initiated from the client, not from the
server. And since client-side script code does not change, no matter the
server-side code (unless the server-side code generates the sending
client-side one), you just send the same request with different data again.

The 1st request was sent by the user typing the URL in the location bar of
his brower.
How do I send the 2nd HTTP request with the user's click of a button?
The server always sends a response, not a request, to the client; this
response can of course include any data you want, including the changed
text file content. So you do not need another request just to show the
updated data, not matter the programming language used to create the
response.

But the user modifications are made after the server send the response
(i.e. the HTML page that the user uses to update the server side text
file). So I still need to send a 2nd HTTP request.
 
W

William

William said:
William wrote:
how do I check what content is being sent over to
http://mkmxg00/cgi/confirmUpload.pl
^^
Ask in a Perl or CGI-related newsgroup about how to process a (POST)
request.

in the XMLHttpRequest?

What you pass as the argument of confirmReq.send() becomes the body of
the request which is evaluated _server-side_. The IXMLHTTPRequest
interface which provides _client-side_ access to the _response_ of the
request does not provide a property to access the request body later.

To make a long story short, I was asked by [another person, whose's
instructions I have to follow] to scrap my code with XMLHttpRequest and
possibly update the server text file with server side javascript.

In case you misunderstood me saying that (client-side) XMLHTTP requests are
a Bad Thing, that was not the case.

Are you saying that you now must implement a JS solution also server-side,
instead of a Perl solution?

I was taking over somebody else's Perl script, and within the Perl script
also contains javascript code.
I am not sure that you understood the difference between client-side and
server-side code, and I am not sure if I understood you correctly. For
one, HTTP requests AIUI you need them to transmit user modifications from
the client to the server have to be initiated from the client, not from the
server. And since client-side script code does not change, no matter the
server-side code (unless the server-side code generates the sending
client-side one), you just send the same request with different data again.

The 1st request was sent by the user typing the URL in the location bar of
his brower.
How do I send the 2nd HTTP request with the user's click of a button?
The server always sends a response, not a request, to the client; this
response can of course include any data you want, including the changed
text file content. So you do not need another request just to show the
updated data, not matter the programming language used to create the
response.

But the user modifications are made after the server send the response
(i.e. the HTML page that the user uses to update the server side text
file). So I still need to send a 2nd HTTP request.
 
T

Thomas 'PointedEars' Lahn

William said:
William said:
how do I check what content is being sent over to
http://mkmxg00/cgi/confirmUpload.pl
^^
[...]
in the XMLHttpRequest?
What you pass as the argument of confirmReq.send() becomes the body of
the request which is evaluated _server-side_. The IXMLHTTPRequest
interface which provides _client-side_ access to the _response_ of the
request does not provide a property to access the request body later.
To make a long story short, I was asked by [another person, whose's
instructions I have to follow] to scrap my code with XMLHttpRequest and
possibly update the server text file with server side javascript.
[...]
Are you saying that you now must implement a JS solution also
server-side, instead of a Perl solution?

I was taking over somebody else's Perl script, and within the Perl script
also contains javascript code.

AFAIK a Perl script cannot contain "javascript code". It can generate
JavaScript code.
The 1st request was sent by the user typing the URL in the location bar
of his brower.

I see.
How do I send the 2nd HTTP request with the user's click of a button?

I do not understand this question, considering the code you posted before.
But the user modifications are made after the server send the response
(i.e. the HTML page that the user uses to update the server side text
file). So I still need to send a 2nd HTTP request.

And what is the problem, exactly?


PointedEars
 

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
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top