Mar 9, 2010

Pulling Hair out over slow Server

Here I am pouring over my code looking for the tiniest things that could be wrong. I have doubled checked all my spellings to see if I had done something simple as that. I changed a couple words to ensure my div tag was spelled the same in the html file and in the javascript file. Then I notice that the file name isn't the same and Dreamweaver added some code in an effort to help me.

So Ok. I finally get the rss feed to pop in the box on load but it will not show up in my div tag. Back to the double checking my spelling. I start comparing line by line one of my team mates working code. I am not seeing any difference beyond my .php file being named differently. Then I notice he didn't have the php file in the scripts folder.

I try moving it to the main folder instead of it being in the scripts folder. After uploading it again, I tried it again. There is nothing showing on the screen. I am thinking what ELSE can be wrong. I put the laptop down and grab the AJAX book looking for any thing that would clue me in as to what I still had wrong.

I look back over at the laptop. My rss feed has popped in to my page in it's own sweet time. I have been pulling my hair out over a slow server response time. GEEEEZZZZ!

My code isn't much but it did work.
function getDetails() {
request = createRequest();
if (request == null) {
alert("Unable to create request");
return;
}
var url= "teaproxy.php";
request.open("GET", url, true);
request.onreadystatechange = displayDetails;
request.send(null);
}

function displayDetails() {
if (request.readyState == 4) {
if (request.status == 200) {
document.getElementById("content").innerHTML = request.responseText;
var test = request.responseXML
test.getElementsByTagName("item");
if (test) {
alert("It is valid XML");
}
}
}
}

function createRequest() {
try {
request = new XMLHttpRequest();
} catch (tryMS) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (otherMS) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
}
}
}
return request;
}

2 comments:

  1. Josette, I wish that I had the same issue. My code never worked. I looked at it for a long time and it never worked. I understand your frustration with it because all ths stuff is a lot to learn at once. I guess next time I'll use my many sources and try to get my program to work even if the server is slow.

    ReplyDelete
  2. I glad to see that things are working now. I have had similar issues and it can get really frustrating. Even things this simple can cause a problem. Your site looks great and I look forward to seeing what you do next.

    ReplyDelete