[ 3 posts ]

codemator

  • Joined: Fri Jan 21, 2011 2:41 am
  • Posts: 2
  • Offline
  • Profile

XHRDataSource not working in firefox

Post Posted: Fri Jan 21, 2011 2:49 am
+0-
I am trying to make autocomplete control working using XHRDataSource . I am using the following example
http://developer.yahoo.com/yui/examples ... quest.html
Here is my Json format
{"ResultSet":{"totalResultsAvailable":2,"Result":[{"cityId":1,"houseId":3,"houseType":1,"position":1,"streetId":1,"zipId":1,"title":"130021|130022"},{"cityId":1,"houseId":4,"houseType":1,"position":2,"streetId":1,"zipId":1,"title":"130022|130023"}]}}

It is working fine in all servers when html page and serverside page(PHP script) on same server or same domain.
If I put the html file on a sub domain and try to access php file on another subdomain in same domain, It is not working (Only in Firefox )

It is fworking fine in all IE versions. right now I am using FF 3.5

Could somebody please help me

My sample code is pasted below
<script type="text/javascript">
YAHOO.example.CitySearchRequest = function() {
// Use an XHRDataSource
var oDS = new YAHOO.util.XHRDataSource("http://l1self32.oskarmobil.cz/~xrenpill/whisperer/fe/www/get_json.php");
// Set the responseType
oDS.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;
// Define the schema of the JSON results
oDS.responseSchema = {
resultsList : "ResultSet.Result",
fields: ["title", "position", "cityId"]
};

// Instantiate the AutoComplete
var oAC = new YAHOO.widget.AutoComplete("txtCity", "cityContainer", oDS);
// Throttle requests sent
//oAC.queryDelay = .5;
// The webservice needs additional parameters
oAC.generateRequest = function(sQuery) {
return "?method=getCityList&cityId=1&query=" + sQuery ;
};
oAC.itemSelectEvent.subscribe(function(type, args) {

var selectedValue = new String(args[2]);
var splitResult = selectedValue.split(',');
var selectedString = splitResult[0];
var selectedStringPosition = splitResult[1];
var selectedStringId = splitResult[2];
document.getElementById('cityId').value=selectedStringId;

/* this line works around Opera's preventDefault
bug: */
YAHOO.util.Dom.get("searchsubmit").disabled = true;
});
return {
oDS: oDS,
oAC: oAC
};
}();
</script>

Alberto Santini

YUI Contributor

  • Offline
  • Profile
Tags:

Re: XHRDataSource not working in firefox

Post Posted: Fri Jan 21, 2011 5:05 am
+0-
Hello codemator

XHR URLs must abide by the same origin policy [1].

Hope that helps,
IceBox




[1] https://developer.mozilla.org/en/Same_o ... JavaScript

codemator

  • Joined: Fri Jan 21, 2011 2:41 am
  • Posts: 2
  • Offline
  • Profile
Tags:

Re: XHRDataSource not working in firefox

Post Posted: Fri Jan 21, 2011 10:53 pm
+0-
In YUI Library example they are claiming XHRDatasource can be used for remote data, that means same orgin policy is not applicable here.

I resolved by problem by using ScriptNodeDataSource instead of XHRDstssource

Thanks a lot for your time..
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum