I have implemented YUI autocomplete in my project by creating a web service that provides suggestions. Everything works fine when both the application and the web service are deployed on the same machine. However, when I deploy the web service on a different machine, the autocomplete feature does not work in Firefox (although it works in IE). I suspect this is due to the same origin policy issue in Mozilla.
Below is the code snippet for the autocomplete feature:
<script type="text/javascript">
YAHOO.example.BasicRemote = function() {
// Using an XHRDataSource to connect to a web service
var oDS = new YAHOO.util.XHRDataSource("http://host_other_than_my_machine/i2b2/services/AutocompleteService/getCodes");
// Set the responseType as XML
oDS.responseType = YAHOO.util.XHRDataSource.TYPE_XML;
// Define the schema of the results
oDS.responseSchema = {
resultNode: 'code',
fields: ['value']
};
// Enable caching
oDS.maxCacheEntries = 0;
// Instantiate the AutoComplete
var oAC = new YAHOO.widget.AutoComplete("myInput", "myContainer", oDS);
return {
oDS: oDS,
oAC: oAC
};
}();
</script>
My questions:
1) Is the same origin policy the actual problem? If yes, then why does it work in IE, which should also adhere to the policy?
2) How can I resolve this issue? I am aware that some PHP code can be used for request redirection, but how can I apply it in this case?
~Ajinkya.