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
https://forums.phpfreaks.com/topic/77841-ajax-working-on-one-domain-not-another/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.