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.opt ions[scroll_list.sel ectedIndex].text = t_area.text;
scroll_list.opt ions[scroll_list.sel ectedIndex].value= t_area.value;
var req;
var url = "http://mkmxg00/cgi/confirmUpload.p l";
if ( window.XMLHttpR equest ) {
try {
req = new XMLHttpRequest( );
}
catch( e ) {
req = false;
}
}
else if ( window.ActiveXO bject ) {
try {
req = new ActiveXObject( "Msxml2.XMLHTTP " );
}
catch( e ) {
try {
req = new ActiveXObject( "Microsoft.XMLH TTP" );
}
catch( e ) {
req = false;
}
}
if ( req ) {
req.onreadystat echange = processReqChang e;
req.open( "POST", url, true );
// req.send( null );
req.send( "client side" );
req.send( "2nd piece of data from client side: " + i + "\n" );
}
}
}
function processReqChang e() {
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:
My questions:
1) what caused the "unterminat ed 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.opt ions[scroll_list.sel ectedIndex].text = t_area.text;
scroll_list.opt ions[scroll_list.sel ectedIndex].value= t_area.value;
var req;
var url = "http://mkmxg00/cgi/confirmUpload.p l";
if ( window.XMLHttpR equest ) {
try {
req = new XMLHttpRequest( );
}
catch( e ) {
req = false;
}
}
else if ( window.ActiveXO bject ) {
try {
req = new ActiveXObject( "Msxml2.XMLHTTP " );
}
catch( e ) {
try {
req = new ActiveXObject( "Microsoft.XMLH TTP" );
}
catch( e ) {
req = false;
}
}
if ( req ) {
req.onreadystat echange = processReqChang e;
req.open( "POST", url, true );
// req.send( null );
req.send( "client side" );
req.send( "2nd piece of data from client side: " + i + "\n" );
}
}
}
function processReqChang e() {
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:
My questions:
1) what caused the "unterminat ed 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.
Comment