Jump to content

AJAX working on one domain, not another


subzerostudio

Recommended Posts

Hi,

 

I have a AJAX "product finder" script that I've written. It is working fine on the main domain:

 

http://www.funkylittlefeet.com

 

However does not work on the alternative domain:

http://www.funkylittlefeet.co.uk

 

Any advice on how to get it working would be appreciated. Code below.

 

Thanks

 

Mike

 

var xmlHttp

function changeMenu(str, menu)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="productfinder_core.php"

var category = document.getElementById('occasionbox').value;
var parent_cat = document.getElementById('parent_cat').value;

if (category != '') {
url=url+"?q="+str+"&menu="+menu+'&cat='+category
} else if (parent_cat != '') {
url=url+"?q="+str+"&menu="+menu+'&cat='+parent_cat+'&useParent=true'
} else {
url=url+"?q="+str+"&menu="+menu
}

url=url+"&sid="+Math.random()

if (menu == 'category') { 
xmlHttp.onreadystatechange=stateChanged
} else if (menu == 'occasion') {
xmlHttp.onreadystatechange=stateChangedBrand
} else { 
xmlHttp.onreadystatechange=stateChangedSize
}

xmlHttp.open("GET",url,true)
xmlHttp.send(null)

}

function stateChanged() { 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 

		 data = xmlHttp.responseText.split('|')
		 document.getElementById("occasion").innerHTML=data[0]
		 document.getElementById("brand").innerHTML=data[1];
		 document.getElementById("size").innerHTML=data[2];
} 
}

function stateChangedBrand() { 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		 data = xmlHttp.responseText.split('|')
		 document.getElementById("brand").innerHTML=data[0]
		 document.getElementById("size").innerHTML=data[1]
} 
}

function stateChangedSize() { 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		 document.getElementById("size").innerHTML=xmlHttp.responseText 
} 
}

function GetXmlHttpObject()
{
var 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");
  }
}
return xmlHttp;
}

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.