Debt Consolidation - Winunited Bonuses - Find jobs - WoW Gold - Debt Consolidation

PDA

View Full Version : Javascript undefined value from subdomain


BlaZingPenguin
Dec 9th 2007, 7:01 am
Hi, I'm fairly new to javascript and I am having an issue with variables when viewing from certain domains while using http.open
this is images.domain.com/js.js, captcha.js works off it
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
var update = new Array();
if(response.indexOf('|' != -1)) {
update = response.split('|');
document.getElementById(update[0]).innerHTML = update[1];
}
}
}

this is captcha.domain.com/captcha.js, and I am trying to open domain/captcha/

http.open('GET', "http://domain.com/captcha/",true);
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
response = http.responseText;
captchaValues = response.split('||');
texttoprint = captchaValues[0];
document.getElementById("ahctpac").innerHTML = texttoprint;


Now heres what happens when I view from these pages, which are all the same pages.
http://register.domain.com/ undefined
http://www.register.domain.com/ undefined
http://domain.com/register/ works
http://www.domain.com/register/ undefined


Is there any reason why with different domains I should be getting undefined results? Is there also a term or phrase that I can look up as to what this might be a result of?

Thanks

*edit*

just tested the undefined urls in ie and I am getting an error of Permission Denied

BlaZingPenguin
Dec 9th 2007, 7:23 am
Thanks for the "JavaScript and AJAX prohibit direct cross-domain scripting." bit, sort of sucks. =[

Fixed the error though, thanks.