/    Sign up×
Community /Pin to ProfileBookmark

AJAX Request Error 500/404..But Why?

Hello everyone…

Site #1 is suppose to load images from an XML file on Site #2. So in the header of Site #1 I’m using this line:

[CODE]
<script language=”JavaScript” src=”http://www.sociallyaffluent.com/volumestat_feed.js”></script>[/CODE]

The JavaScript AJAX call is the same one that I use to make a successful call for another feature on another site. So I’m not understanding why I’m getting a 500 or 404 error… Can anyone see anything?

Code:

[CODE]
// JavaScript Document

window.onload=function(){

xmlSearch();

}

function xmlSearch(){

var browsername=navigator.appName;
var browserversion=parseInt(navigator.appVersion);

var request=null;
var xml_response=null;

if (window.XMLHttpRequest) {

request=new XMLHttpRequest();

} else if (window.ActiveXObject) {

request= new ActiveXObject(“Microsoft.XMLHTTP”);

}

if (request){

var url_xml = “vstat_images.xml?dt=”+new Date().getTime();

request.open(“GET”,url_xml);

request.onreadystatechange=

function(){

if ((request.readyState==4)&&(request.status==200)){

if ((browsername.indexOf(“Microsoft”) != -1) && (browserversion >= 4)){

xml_response=new ActiveXObject(“Microsoft.XMLDom”);

xml_response.loadXML(request.responseText);
}
else
{
xml_response=request.responseXML;
}

displayXMLFile(xml_response);

}

else if ((request.status==500)||(request.status==404))
{ alert(“Sorry having loading issues.”)}
}
request.send(null);

}else{

alert(“Sorry, update the browser to see Ajax in action”);

}

}

function displayXMLFile(xml_response){

document.write(‘<div style=”border-bottom:1px solid #6a6a6a; width:300px; height:25px; color:#6a6a6a; font-family:Times New Roman; font-size:22px;”>ATL Events</div>’);

document.write(‘<div style=”width:300px; height:750px; margin-top:5px;”>’);

var targ_item=xml_response.getElementsByTagName(‘item’)[0];

var img1=targ_item.getElementsByTagName(‘img1’)[0].firstChild.data;
var img2=targ_item.getElementsByTagName(‘img2’)[0].firstChild.data;
var img3=targ_item.getElementsByTagName(‘img3’)[0].firstChild.data;
var img4=targ_item.getElementsByTagName(‘img4’)[0].firstChild.data;
var img5=targ_item.getElementsByTagName(‘img5’)[0].firstChild.data;
var img6=targ_item.getElementsByTagName(‘img6’)[0].firstChild.data;

document.writeln(‘<div style=”margin-top:0px; margin-left:-1px;”><a href=”http://www.sociallyaffluent.com” target=”_blank”><img src=”‘+$img1+'” width=”110″ height=”126″ /></a></div>’);

document.writeln(‘<div style=”margin-top:-131px; margin-left:115px;”><a href=”http://www.sociallyaffluent.com” target=”_blank”><img src=”‘+$img2+'” width=”110″ height=”126″ /></a></div>’);

document.writeln(‘<div style=”margin-top:5px; margin-left:-1px;”><a href=”http://www.sociallyaffluent.com” target=”_blank”><img src=”‘+$img3+'” width=”110″ height=”126″ /></a></div>’);

document.writeln(‘<div style=”margin-top:-131px; margin-left:115px;”><a href=”http://www.sociallyaffluent.com” target=”_blank”><img src=”‘+$img4+'” width=”110″ height=”126″ /></a></div>’);

document.writeln(‘<div style=”margin-top:5px; margin-left:-1px;”><a href=”http://www.sociallyaffluent.com” target=”_blank”><img src=”‘+$img5+'” width=”110″ height=”126″ /></a></div>’);

document.writeln(‘<div style=”margin-top:-131px; margin-left:115px;”><a href=”http://www.sociallyaffluent.com” target=”_blank”><img src=”‘+$img6+'” width=”110″ height=”126″ /></a></div>’);

document.writeln(‘</div>’);

document.writeln(‘<div style=”margin-left:0px; margin-top:0px;”><a href=”http://www.sociallyaffluent.com” target=”_blank”><img style=”border:none;” src=”http://www.sociallyaffluent.com/Images/sa_vol_logo.jpg”></a></div>’);

}

[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ChuckBauthorAug 04.2010 — So does http://www.sociallyaffluent.com/vstat_images.xml exist?[/QUOTE]

Yeah it does. I was able to develop a PHP solution and it worked with the same file. I just have to do a JavaScript version because of difficulty integrating the PHP solution with Wordpress. (It should be easy since Wordpress is developed with PHP, but I'm taking the easyway out :rolleyes: )

If you click the link and right click the page, you'll see the code for the xml file. All it is, is a xml file with image locations.
×

Success!

Help @ChuckB spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...