using xmlHTTP.responseText in any other java function
is it possible to use the xmlHTTP.responseText in any other java function, after execuation of stateChanged() function??? example in ajax...
function stateChanged(){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
var result = xmlHttp.responseText
if (result.length=="0"){
var task = "do"; //i want to use "task" in other js function
return task;
}
}
}
i used many ways (a little bit i know) to do but could not get the success. how can we do???
any thoughts please......
servis
Junior Poster in Training
82 posts since May 2008
Reputation Points: 10
Solved Threads: 0
servis
Junior Poster in Training
82 posts since May 2008
Reputation Points: 10
Solved Threads: 0
sorry essential, i used every method including all the instructions given by you, but no success....
servis
Junior Poster in Training
82 posts since May 2008
Reputation Points: 10
Solved Threads: 0
its runnung very much fine....your solutions are always give me something different....thinking of doing things differently....
when i test the following....it does not respond...please can you help where i am comitting mistake...
<?php
session_start();
if ( !empty( $_GET['id'] ))
{
include("securimage.php");
$img = new Securimage();
$valid = $img->check( $_GET['id'] );
if ($valid == true){
$response = "Code is Correct";
}
echo $response;
} else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html id="html4" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>Live Help!</title>
<script type="text/javascript">
var req;
var handleRequest = function() {
if (req) {
if (req.readyState == 4 || req.status == "complete") {
respond = req.responseText;
if ( respond.length === "0" ) {
task = "incorrect"; // This value will be available if the user send active request.
}
}
} else { task = "correct"; }
};
var sendRequest = function(str) {
if(str==""){alert("please enter the code"); return;}
req = null;
url = "test3.php?id=" + str;
method = "GET";
try {
if ( window.XMLHttpRequest ) {
req = new XMLHttpRequest();
} else if ( window.ActiveXObject ) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch( e1 ) {
req = new ActiveXObject("Msxml2.XMLHTTP");
}
}
} catch( e2 ) {
(( window.createRequest ) ? req = window.createRequest() : req = null );
}
(( req.overrideMimeType ) ? req.overrideMimeType("text/xml") : req );
if ( req !== null ) {
req.onreadystatechange = handleRequest;
req.open( method, url, true );
(( req.setRequestHeader && method === "POST" ) ? req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") : req );
req.send( null );
} else {
alert("\nYour browser does not support AJAX Request!");
}
};
var checkVar = function() {
if (task == "correct"){
alert("the script runs fine"); } else { alert("incorrect"); }
}
// -->
</script>
</head>
<body>
<form method="POST">
<!-- pass a session id to the query string of the script to prevent ie caching -->
<img src="securimage_show.php?sid=<?php /*><!--?*/ echo md5(uniqid(time())); /*--><?*/ ?>">
<input type="text" name="code" onblur="sendRequest(this.value); checkVar();"/>
<input type="submit" value="Submit Form" />
</form>
<div id ="response">Response will be display here!</div>
</body>
</html>
<?php
}
?>
thank you for the solutions....
servis
Junior Poster in Training
82 posts since May 2008
Reputation Points: 10
Solved Threads: 0
thank you very much.............its working now, after your advised ammendments.......
servis
Junior Poster in Training
82 posts since May 2008
Reputation Points: 10
Solved Threads: 0