Jump to content

javascript and ajax


dreamwest

Recommended Posts

So ive called a page with ajax but the called page's javascript doesnt work, what am i missing??

 

main.html

<script>
function Data($Request, $Control, $jump, $player) {

	if($jump){
	window.location = String(window.location).replace(/\#.*$/, "") + "#top";
	}
	if($player){
	document.getElementById("more").style.display = "block";
	}
	if ($Control == "" || $Control == null)	{alert ("No output specified !"); return;}
	var ai = new AJAXInteraction($Request, GetServerData,  $Control );
	ai.doGet();
}


function GetServerData  ($TheData, $Control){
	document.getElementById($Control).innerHTML = $TheData;
}

function AJAXInteraction(url, callback, $Control) {
   	var req = init();
    req.onreadystatechange = processRequest;
        
    	function init() {
		if	(window.XMLHttpRequest)		{	return new XMLHttpRequest();					} 
		else if (window.ActiveXObject)	{	return new ActiveXObject("Microsoft.XMLHTTP");  }
		else {alert ("Your browser seems to be out of date, Please update!"); return;		}
    }
    
    	function processRequest () {
		if (req.readyState == 4) {
	        if (req.status == 200) callback(req.responseText, $Control);
		}
		else	callback(Myvar , $Control);
    }
	this.doGet = function() {
      req.open("GET", url, true);
    	  req.send(null);
    }
    
    
   }
</script>

<span onclick='Data("/page.html", "T"); return false;'>Click</span>

<ul id='T'></ul>

 

 

page.html

<script src='/jquery_tools.js'></script>
..javascript stuff here

Link to comment
Share on other sites

Ok this i everthing relevant

 

ajax.js

	function Data($Request, $Control, $jump, $player) {

	if($jump){
	window.location = String(window.location).replace(/\#.*$/, "") + "#top";
	}
	if($player){
	document.getElementById("more").style.display = "block";
	}
	if ($Control == "" || $Control == null)	{alert ("No output specified !"); return;}
	var ai = new AJAXInteraction($Request, GetServerData,  $Control );
	ai.doGet();
}


function GetServerData  ($TheData, $Control){
	document.getElementById($Control).innerHTML = $TheData;
}

function AJAXInteraction(url, callback, $Control) {
   	var req = init();
    req.onreadystatechange = processRequest;
        
    	function init() {
		if	(window.XMLHttpRequest)		{	return new XMLHttpRequest();					} 
		else if (window.ActiveXObject)	{	return new ActiveXObject("Microsoft.XMLHTTP");  }
		else {alert ("Your browser seems to be out of date, Please update!"); return;		}
    }
    
    	function processRequest () {
		if (req.readyState == 4) {
	        if (req.status == 200) callback(req.responseText, $Control);
		}
		else	callback(Myvar , $Control);
    }
	this.doGet = function() {
      req.open("GET", url, true);
    	  req.send(null);
    }
    
    
   }

 

 

main.html

<script src="/ajax.js"></script>
<span onclick='Data("/page.html", "T"); return false;'>Click</span>
<ul id='T'></ul>

 

 

page.html

<script src="/ajax.js"></script>
<span onclick='Data("/test.html", "T"); return false;'>Click</span>

 

test.html

page.html has initiated this page

 

So the javascrpt in page.html isnt getting initiated

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.