Hello there,
I’m relatively new to Javascript so please forgive me if I’m making some obvious mistake here.
I’m just trying to get a simple form to send an xmlhttprequest to a php script which returns basic info (at this stage) based on the $_GET variable it receives.
It looks to me that I’m just not getting anything back from the server but the php is fine. At least, it works fine when not called by xmlhttprequest.
Any help would be greatly appreciated.
B
Here’s a link to the non-working example:
[url]http://www.invisibleforce.net/dragme_f/try.html
And here’s the HTML/javascript I’m using:
<code>
<!DOCTYPE html PUBLIC “-//WC3//DTD XHTML 1.0 Strinct//EN”
“
<html>
<head><title>XMLHTTPOBJECT TEST</title>
<script type=”text/javascript”>
function getText() {
var url = “reply.php?keywords=” + document.keyform.keywords.value;
alert(url);
var request = GetXmlHttpObject();
request.onreadystatechange = function() {
if (request.readyState == 4 || request.readyState==”complete”){
alert(“ready: ” + readyState);
document.getElementById(“results”).innerHTML=request.responseText
}
}
if(request){
request.open(“GET”, url, false);
request.send(null);
alert(“sent”);
}else alert(“-NotWorking-“);
};
</script>
<script type=”text/javascript”>
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (e)
{
xmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
}
return xmlHttp;
};
</script>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″/>
<link rel=”STYLESHEET” type=”text/css” href=”draggable.css”/>
</head>
<body>
<div class=”content”>
<form method=”GET” action =”” name=”keyform”>
keywords: <input type=”text” name=”keywords” id=”keywords” size=”50″/>
<input type=”submit” name=”submit” value=”submit” onclick=”getText()”/>
</form>
</div>
<div id=”results”>
RESULTS GO HERE!
</div>
</body></html>
</code>
And here’s the php:
<code>
<?php
if(isSet ($_GET[‘submit’])){
$f_search = $
echo “Well Done!: ” .$f_search;
}else echo “GET NOT SET”;
?>
</code>