Does this websit support AJAX?


#1

I am trying to test Ajax does this website support Ajax.


#2

It should do! :slight_smile:


#3

Thank You for your reply. I am using the code below. It does not seem to change the text in data.txt.
Here is my code: Please let me know if you can help me.

<!DOCTYPE html>
<html>
<head>
	<title>Ajax Lesson</title>
	<script>
		function getDataFromText(){
		var xmlhttp;
		if(window.XMLHtppRequest){
			xmlhttp = new XMLHtppRequest();
		
		}else{
			xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState ==4 && xmlhttp.status==200){
			document.getElementById('data').innerHTML=xmlhttp.responseText;
			}
			}
			xmlhttp.open("GET","data.txt",true);
			xmlhttp.send();
			}
			</script>
</head>
<body>
<div id="data"><h2>Replace this text</h2></div>
<button type="button" onclick="getDataFromText()">Get Data</button>

</head>

</body>
</html>

#4

Hi @pkn

Do you need to change the text of data.txt? or get data from it and print it?

Mention your website address too.


#5

I think he wants to modify data in it.


#6

Make sure you check your JavaScript console in your browser, and also your Network console. The JS console should have no errors, and the Network console will allow you to watch the request and response in real-time as your AJAX operation is made.

As @Supun says, if we can have a link, that will give us something to look at.


#7

one minor typo;
Change XMLHtppRequest to XMLHttpRequest

if(window.XMLHttpRequest){
			xmlhttp = new XMLHttpRequest();

#8

Hi Supun,

Get data from the data.txt file and print it


#9

Thank You for your help halfer


#10

Thank You for your help Mortenrb, I will change that


#11

Is your issue fixed now @pkn