Can Ajax work across domains??
Posted: Tue Mar 20, 2012 10:25 am
If this is hosted on the same server as the hosted site, it works (minus the extra http://.....)/.
But if it is hosted on an external site, can you run this cross-domains? The site the text field is being entered on is not hosted on the site that the page in the script is hosted on.
The external site host does not permitted external db links, but would this count? Seeing as it's being passed thru to the action hosted domain?
But if it is hosted on an external site, can you run this cross-domains? The site the text field is being entered on is not hosted on the site that the page in the script is hosted on.
The external site host does not permitted external db links, but would this count? Seeing as it's being passed thru to the action hosted domain?
Code: Select all
<script>
function precheck(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("srcHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","http://www.domain.co.uk/ajax_addproduct.php?q="+str,true);
xmlhttp.send();
}
</script>