Hi,
I read about ajax calls and I thought that ajax calls was the solution to my problem in creating a chat room. After I had read the tutorial carefully, I tried to write my own ajax call code and when i uploaded the file to a free server it didn't work. I thought that maybe the code was wrong, but when i read it again it was correct. So I went to the tutorial and I copied the example code that I knew it was working. I created all the necessary files for the example to work, but again nothing happened. What I am trying to do is to access a txt file and read its content. Another thing with my server is that when i try to access a txt file, a white blank page is the result, when in other servers when I access a txt file i get the content of the file. My question is: Is it possible that a server does not support ajax calls?
Not that I am aware of. AJaX is JavaScript (client-side) and XML. When you use AJaX to asynchronously access a script on the server, it is usually doing so in the background, seamlessly working. Check browser error console for messages.
__________________ ^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
You were right WolfShade.
I get a 404 error., However I have created the file. What are the possible reasons for that error and how can resolve the problem?
A 404 error is "not found". Are you sure you typed the path to the file correctly?
__________________ ^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
The name of the txt file is test.txt and it is located in the same folder as the html file that contains the AJaX call. The code that I have write is the following.
<CODE>
<html>
<head>
<title>Test</title>
</head>
<body>
Procedure started
<script type="text/javascript">
var myrequest;
kala();
function kala() {
if (window.XMLHttpRequest) {
myrequest=new XMLHttpRequest();
}
else {
myrequest= new ActiveXObject('Microsft.XMLHTTP');
}
To wrap code in tags, use square brackets, not greater-than and less-than:
Code:
<html>
<head>
<title>Test</title>
</head>
<body>
Procedure started
<script type="text/javascript">
var myrequest = new kala();
myrequest.open("GET",'[url to your server]/test.txt',true);
myrequest.send(null);
myrequest.onreadystatechange=getData();
function kala() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
else {
return new ActiveXObject('Microsft.XMLHTTP');
}
}
function getData() {
if (myrequest.readyState===4) {
if (myrequest.status===200) {
var text=myrequest.responseText;
alert(text);
}
}
}
</script>
</body>
</html>
Untested, but I think this will do it.
__________________ ^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
Thanks, but it didn't work.
Is it normal that when i try to access the txt file with the browser i get an empty page when the file is not empty?
That depends upon what is in the txt file. If it's XML or HTML code without content, it can appear blank. Do a "View Source" to see if it really is blank.
__________________ ^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".