Login   Register  
PHP Classes
elePHPant
Icontem

File: newsbox.ajax.js

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Russell Nash  >  News Box  >  newsbox.ajax.js  >  Download  
File: newsbox.ajax.js
Role: Auxiliary data
Content type: text/plain
Description: newsbox.ajax.js
Class: News Box
Display random news items stored in a file
Author: By
Last change:
Date: 7 years ago
Size: 1,377 bytes
 

Contents

Class file image Download
<!-- 
var http = createRequestObject();
var objectId = '';
createRequestObject('NewsBox');
// change the location of the PhpProgramLoc to match the location of the php newsbox file
var PhpProgramLoc = 'http://localhost/php%20classes/newsbox/newsbox.php';
sendReq(PhpProgramLoc,'disp','ajax');
function createRequestObject(htmlObjectId){
    var obj;
    var browser = navigator.appName;    
    objectId = htmlObjectId;    
    if(browser == "Microsoft Internet Explorer"){
        obj = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
        obj = new XMLHttpRequest();
    }
    return obj;    
}
function sendReq(serverFileName, variableNames, variableValues) {
	var paramString = '';	
	variableNames = variableNames.split(',');
	variableValues = variableValues.split(',');
	
	for(i=0; i<variableNames.length; i++) {
		paramString += variableNames[i]+'='+variableValues[i]+'&';
	}
	paramString = paramString.substring(0, (paramString.length-1));
			
	if (paramString.length == 0) {
	   	http.open('get', serverFileName);
	}
	else {
		http.open('get', serverFileName+'?'+paramString);
	}
    http.onreadystatechange = handleResponse;
    http.send(null);
}
function handleResponse() {	
	if(http.readyState == 4){
		responseText = http.responseText;
		document.getElementById(objectId).innerHTML = responseText;
    }
}
-->