|
lesson 54
|
we can show the output data of any file in required page
|
|
its best for customer who using payement page
|
|
|
without loading , how tot get
the text file data
|
|
|
<?php
|
|
|
echo rand(111,999) .'<br><br>';
|
to print random number
|
|
|
|
|
?>
|
|
|
without page load, get the file and displayed in div
|
|
|
ajaxindex.php
|
|
|
<html>
|
|
|
<head>
|
|
|
<script>
|
|
|
function load(thediv, thefile){
|
|
|
if(window.XMLHttpRequest){
|
|
|
xmlhttp = new XMLHttpRequest();
|
|
|
} else{
|
ist checks the browser
|
|
xmlhttp =new ActiveXobject('Microsoft.XMLHTTP');
|
|
|
}
|
|
|
xmlhttp.onreadystatechange = function(){
|
|
|
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
|
after what to do if the response is received
|
|
document.getElementById(thediv).innerHTML =
xmlhttp.responseText;
|
load that response to the div element
|
|
}
|
|
|
}
|
|
|
xmlhttp.open('GET', thefile, true);
|
send the request to get rhymes.txt
|
|
xmlhttp.send();
|
|
|
|
|
|
}
|
|
|
</script>
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
|
|
|
<input type="submit" onclick ="load('adiv',
'RHYMES.txt')" value="submit">
|
wheenver click load function happened
|
|
<br>
|
|
|
<div id="adiv"> </div>
|
|
|
</body>
|
|
|
</html>
|
|
|
some.php
|
if we write this file name in .open, it will print this file
data
|
|
<?php
|
|
|
echo '<br> <br> welcome to telugu world';
|
|
|
?>
|
|
|
rhymes.txt
|
we displayed this in that file
|
|
after event is finished we display some data
|
|
|
Five little monkeys jumping on the bed,<br><br>
|
|
|
One fell down and bumped his head,<br><br>
|
|
|
Mama called the doctor and the doctor said,<br><br>
|
|
|
No more monkeys jumping on the bed!<br><br>
|
|
|
<br><br>
|
|
|
Four little monkeys jumping on the bed,<br><br>
|
|
|
One fell down and bumped his head,<br><br>
|
|
|
Mama called the doctor and the doctor said,<br><br>
|
|
|
No more monkeys jumping on the bed!<br><br>
|
|
|
<br><br>
|
|
|
Three little monkeys jumping on the bed,<br><br>
|
|
|
One fell down and bumped her head,<br><br>
|
|
|
Mama called the doctor and the doctor said,<br><br>
|
|
|
No more monkeys jumping on the bed!<br><br>
|
|
|
<br><br>
|
|
|
Two little monkeys jumping on the bed,<br><br>
|
|
|
One fell down and bumped his head,<br><br>
|
|
|
Mama called the doctor and the doctor said,<br><br>
|
|
|
No more monkeys jumping on the bed!<br><br>
|
|
|
<br><br>
|
|
|
One little monkey jumping on the bed,<br><br>
|
|
|
She fell down and bumped her head,<br><br>
|
|
|
Mama called the doctor and the doctor said,<br><br>
|
|
|
Put those monkeys back to bed!<br><br>
|
|
| window.XMLHttpRequest |
| xmlhttp = new XMLHttpRequest |
| new ActiveXobject('Microsoft.XMLHTTP') |
| xmlhttp.onreadystatechange |
| xmlhttp.readystate |
| xmlhttp.status |
| xmlhttp.open('GET', thefile, true); |
| xmlhttp.send(); |
| onclick |
| how to check browser is support or not |
| how to check if this browser is not supoprt |
| how to ready to get the response |
| how to check server is sent the fille or not |
| how to load the data from server |
| what request have to send |
| how to send the request |
No comments:
Post a Comment