W
William
I have the following javascript function that updates a scroll_list and
sends the updated entry (with its index) to a server script
( i.e. http://mkmxg00/cgi/confirmUpload.pl ) for further processing:
function saveText( scroll_list, t_area, listToBeUpdated ) {
scroll_list.options[scroll_list.selectedIndex].text = t_area.text;
scroll_list.options[scroll_list.selectedIndex].value= t_area.value;
var req;
var url = "http://mkmxg00/cgi/confirmUpload.pl";
if ( window.XMLHttpRequest ) {
try {
req = new XMLHttpRequest();
}
catch( e ) {
req = false;
}
}
else if ( window.ActiveXObject ) {
try {
req = new ActiveXObject( "Msxml2.XMLHTTP" );
}
catch( e ) {
try {
req = new ActiveXObject( "Microsoft.XMLHTTP" );
}
catch( e ) {
req = false;
}
}
if ( req ) {
req.onreadystatechange = processReqChange;
req.open( "POST", url, true );
// req.send( null );
req.send( "client side" );
req.send( "2nd piece of data from client side: " + i + "\n" );
}
}
}
function processReqChange() {
alert( req.readyState );
if ( req.readyState == 4 ) {
if ( req.status == 200 ) {
// process the response if successful
alert( "passed!" );
}
}
else {
alert( req.readyState + ", " + req.status );
}
}
I tried the following reference:
http://www.xml.com/pub/a/2005/02/09/xml-http-request.html
My questions:
1) what caused the "unterminated string constant error"? I don't see any
', \r, etc in my javascript variables.
2) If I want to send() to the server the scroll_list option, and that
option's index to the server script http://mkmxg00/cgi/confirmUpload.pl
for further processing, am I using send() correctly? If not, please
correct by providing an example.
sends the updated entry (with its index) to a server script
( i.e. http://mkmxg00/cgi/confirmUpload.pl ) for further processing:
function saveText( scroll_list, t_area, listToBeUpdated ) {
scroll_list.options[scroll_list.selectedIndex].text = t_area.text;
scroll_list.options[scroll_list.selectedIndex].value= t_area.value;
var req;
var url = "http://mkmxg00/cgi/confirmUpload.pl";
if ( window.XMLHttpRequest ) {
try {
req = new XMLHttpRequest();
}
catch( e ) {
req = false;
}
}
else if ( window.ActiveXObject ) {
try {
req = new ActiveXObject( "Msxml2.XMLHTTP" );
}
catch( e ) {
try {
req = new ActiveXObject( "Microsoft.XMLHTTP" );
}
catch( e ) {
req = false;
}
}
if ( req ) {
req.onreadystatechange = processReqChange;
req.open( "POST", url, true );
// req.send( null );
req.send( "client side" );
req.send( "2nd piece of data from client side: " + i + "\n" );
}
}
}
function processReqChange() {
alert( req.readyState );
if ( req.readyState == 4 ) {
if ( req.status == 200 ) {
// process the response if successful
alert( "passed!" );
}
}
else {
alert( req.readyState + ", " + req.status );
}
}
I tried the following reference:
http://www.xml.com/pub/a/2005/02/09/xml-http-request.html
My questions:
1) what caused the "unterminated string constant error"? I don't see any
', \r, etc in my javascript variables.
2) If I want to send() to the server the scroll_list option, and that
option's index to the server script http://mkmxg00/cgi/confirmUpload.pl
for further processing, am I using send() correctly? If not, please
correct by providing an example.