I am new to webspeed and are trying to pickup some knowledge about ajax and webspeed. I ran in to a problem i don't seem to figure out:
When using external javascript file, firebug reports that function callServer() is not defined. The webspeed file and the .js file is located in the same directory.
ajax06.r looks like this:
ajax.js looks like this:
Using Firebug in Firefox I get these errors
------------------------------------------------------------------
unexpected end of XML source
[Break on this error] <!-- Generated by Webspeed: http://www.webspeed.com/ -->\ ajax.js (line 4)
------------------------------------------------------------------
<BR>Unable to find web object file 'are/ajax.js'<BR>
<!-- Generated by Webspeed: http://www.webspeed.com/ -->
------------------------------------------------------------------
when trying to run function callServer:
callServer is not defined
function onclick(event) { callServer("cgi-bin/wspd_cgi.sh/are/findxmlcustomer.r", "<custNum>" + document.getElementById("custNum").value + "</custNum>"); document.getElementById("myContainer").innerHTML = gRequest.responseXML.firstChild.firstChild.nodeValue; }(click clientX=260, clientY=87)
I have placed ajax06 as plain html file on another webserver (not webspeed) and placing ajax.js in the same directory. The javascript functions is access correctly then...
Could anybody help me figure out what I am doing wrong? :blush1:
the webspeed server is running on unix, and the testfiles reside in the directory: /cgi-bin/wspd_cgi.sh/are/
When using external javascript file, firebug reports that function callServer() is not defined. The webspeed file and the .js file is located in the same directory.
ajax06.r looks like this:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script language="javascript" type="text/javascript" src="ajax.js">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Making Progress with Ajax</title>
</head>
<body>
<h2>Ajax <--> Progress</h2>
<form action="">
<table>
<tr>
<td align="right">Kundenr:</td>
<td><input type="text" id="custNum" /></td>
<td><input type="button" value="Vis kunde"
onclick="callServer('cgi-bin/wspd_cgi.sh/are/findxmlcustomer.r',
'<custNum>' + document.getElementById('custNum').value + '</custNum>');
document.getElementById('myContainer').innerHTML =
gRequest.responseXML.firstChild.firstChild.nodeValue;" /></td>
</tr>
<tr>
<td colspan="3"><div id="myContainer" /></td>
</tr>
</table>
</form>
</body>
</html>
ajax.js looks like this:
Code:
var gRequest;
function createRequest() {
var xmlhttp;
if (window.XMLHttpRequest)
{
// Kode for IE7 +, Firefox, Chrome, Opera, Safari
return xmlhttp=new XMLHttpRequest();
}
else if (windows.ActiveXObject)
{
// Kode for IE6, IE5
return xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
alert("Din nettleser støtter ikke XMLHTTP!");
}
} // create request.
function callServer(url, data) {
gRequest = createRequest();
gRequest.open("POST", url, false);
gRequest.setRequestHeader("Content-Type", "text/xml");
gRequest.send(data);
} // callserver
Using Firebug in Firefox I get these errors
------------------------------------------------------------------
unexpected end of XML source
[Break on this error] <!-- Generated by Webspeed: http://www.webspeed.com/ -->\ ajax.js (line 4)
------------------------------------------------------------------
<BR>Unable to find web object file 'are/ajax.js'<BR>
<!-- Generated by Webspeed: http://www.webspeed.com/ -->
------------------------------------------------------------------
when trying to run function callServer:
callServer is not defined
function onclick(event) { callServer("cgi-bin/wspd_cgi.sh/are/findxmlcustomer.r", "<custNum>" + document.getElementById("custNum").value + "</custNum>"); document.getElementById("myContainer").innerHTML = gRequest.responseXML.firstChild.firstChild.nodeValue; }(click clientX=260, clientY=87)
I have placed ajax06 as plain html file on another webserver (not webspeed) and placing ajax.js in the same directory. The javascript functions is access correctly then...
Could anybody help me figure out what I am doing wrong? :blush1:
the webspeed server is running on unix, and the testfiles reside in the directory: /cgi-bin/wspd_cgi.sh/are/