Hi there
I have the following web page trying to do a ajax post to a coldfusion page which inserts data to a file:
dave.html:
<!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"
>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<script type="text/javascript" src="prototype.js">
</script>
<script type="text/javascript" src=
"scriptaculous.js">
</script>
<script type="text/javascript">
//new Ajax.Request('saveportal.cfm', {asynchronous:true});
function displaymessage()
{
var opt = {
// Use POST
method: 'post',
// Send this lovely data
postBody: escape('thisvar=true&thatvar=Howdy&t
heothervar
=2112'),
// Handle successful response
onSuccess: function(t) {
alert(t.responseText);
},
// Handle 404
on404: function(t) {
alert('Error 404: location "' + t.statusText + '" was not found.');
},
// Handle other errors
onFailure: function(t) {
alert('Error ' + t.status + ' -- ' + t.statusText);
}
}
new Ajax.Request('
http://10.5.0.2/saveportal.cfm',
opt);
}
</script>
<body>
<input type="button" value="Click me!" onclick="displaymessage()" >
</body>
</html>
Coldfusion page saveportal.cfm:
<cffile action="write" addnewline="yes" file="c:\dave.txt" output="Page Hit" fixnewline="yes">
When I run dave.html, there is a slight pause and I get 500 -- Internal Server Error, i.e the failure function. I am new to Ajax and I have no idea what this could be, is the set up incorrect, do I need to do anything special in coldfusion etc etc??
Also if I open the coldfusion page by itself it works fine.
Any help would be much appreciated!
Thanks