Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script language="javascript">
- // The Ajax //
- var dataTimer = "";
- function startLookup() {
- sendRequest();
- }
- function StartTimer() {
- setInterval("sendRequest()", 1000);
- }
- function createRequestObject() {
- StartTimer();
- var req;
- if(window.XMLHttpRequest){
- // Firefox, Safari, Opera...//
- req = new XMLHttpRequest();
- } else if(window.ActiveXObject) {
- // Internet Explorer 5+//
- req = new ActiveXObject("Microsoft.XMLHTTP");
- } else {
- //error//
- alert('Problem creating the XMLHttpRequest object');
- }
- return req;
- }
- // Make the XMLHttpRequest object
- var http = createRequestObject();
- function sendRequest(position) {
- // Open PHP script for requests
- http.open('get', 'show.php');
- http.onreadystatechange = handleResponse;
- http.send(null);
- }
- function handleResponse() {
- if(http.readyState == 4 && http.status == 200){
- // Text returned FROM the PHP script
- var response = http.responseText;
- if(response) {
- // UPDATE ajaxTest content
- document.getElementById("searchResults").innerHTML = response;
- }
- }
- }
- </script>
Add Comment
Please, Sign In to add comment