Jump to content

XMLHttpRequest not accessible from function....


nmullen

Recommended Posts

For some reason my XMLHttpRequest object is not able to be accessed from one of my functions for whatever reason.

 

Here is my automate function which is called when a button is clicked:

 

function Automate()
{	
var url = "";
var index = 0;
var i;
var list = document.getElementById("lstKWs");

//Automate Clicked
progression = 1;

//Fills the keyword list
FillKWs();

//If no keywords are present
if (list[0] == null || list[0].text == "---Click to Populate---")
{
	alert("Please Enter Keywords");
	document.getElementById("txtKWs").focus();
	return false;
}

initializeArrays();

//Initializes the xmlHttp Object
getSingleXMLHttpObject();

while (!xmlHttp)
{
	alert("XML HTTP WASNT SET");
	getSingleXMLHttpObject();
}

//Opens phpCall
//Starts a chain of calling sequences
var url="_includes/phpCall.php";
//Calls the adjust pagerank in waiting for a readyState = 4
xmlHttp.onreadystatechange=AdjustPageRank;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

 

near the end of the function it calls AdjustPageRank everytime there is a state change!  Here is my AdjustPageRank function which seems to fail to recognize the xmlHttp object.  I keep getting the error:

 

Error: xmlHttp has no properties

Source File: "..."  - I Deleted the file directory

Line: 573

 

function AdjustPageRank() 
{ 
var index;
var rank;

if (xmlHttp.readyState==4)
{ 

	rank = xmlHttp.responseText;

	//Depending on page rank update radio buttons
	if (rank >6.9)
		document.getElementById("Linking_PageRank_0").checked = true
	else if (rank > 3.9)
		document.getElementById("Linking_PageRank_1").checked = true
	else
		document.getElementById("Linking_PageRank_2").checked = true


	//Calling the getGooglePages and concatenating the length of the keywords
	url="_includes/getGooglePages.php?KWLength=" + KWs.length;

	//Puts the array of keywords onto the URL
	for (index = 0;index<KWs.length;index++)
		url += "&keyword" + index + "=" + KWs[index];

		var xmlHttp = getSingleXMLHttpObject();
		//When the state changes call the getPages
		xmlHttp.onreadystatechange = getGooglePages;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);


}
}

 

Also here's my getSingleXMLHttpObject

 

function getSingleXMLHttpObject()
{
xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
}

Any ideas on why my adjustpagerank function is reading my xmlHttp as having no properties? 

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.