jQWidgets Forums
jQuery UI Widgets › Forums › Grid › DataAdapter issue with Firefox and Chrome
This topic contains 8 replies, has 2 voices, and was last updated by Mark 12 years, 3 months ago.
-
Author
-
Hi,
I have a simple grid populated by a json datasource below
var elements_source = { datatype: "json", datafields: [ { name: 'ElementID' }, { name: 'Name' }, { name: 'Value' }, { name: 'ChannelID' }, { name: 'MultiAnswer' }, { name: 'Column' }, { name: 'Schema' } ], url: '@ViewBag.URL/Admin.svc/Elements' } var da_Elements = new $.jqx.dataAdapter(elements_source, { downloadComplete: function (data, status, xhr) { }, loadComplete: function (data) { }, loadError: function (msg, status, error) { alert(msg.responseText); } })
This works fine on Internet Explorer and i see rows correctly populated in a grid, however on Chrome and Firefox the loadError callback is hit however the responseText is empty. You can see a working example of this issue Here
Any ideas on what this might be?
Thanks
Mark
Hi Mark,
Here is the error from Chrome: XMLHttpRequest cannot load http://leadmesh.cloudapp.net/Admin.svc/Elements?filterscount=0&groupscount=0&pagenum=0&pagesize=10&recordstartindex=0&recordendindex=18. Origin http://leadmesh.cloudapp.net:8080 is not allowed by Access-Control-Allow-Origin.
You probably need to do “POST” instead of “GET” in your app.
In addition, please read this help topic: jquery-grid-extra-http-variables.htm.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comExcellent – thanks for the quick response Peter.
Hi Mark,
In addition, if you make cross-domain calls, use “jsonp” as type, because due to the cross-domain policy, “json” will not work there.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
I have been doing some research on this today following on from your feedback and I am unfortunately still confused why I am seeing this issue as I am visiting the same domain – the only difference is the port, and from what I have read this issue only occurs when you are going to different domains. As mentioned, this works fine in IE, but not Chrome or Firefox.
The reason I have this as a GET is because the call is idempotent and I want to show this to my consumers if possible.
Any pointers would be greatly appreciated.
Cheers
Mark
Hi Mark,
The reason it works in IE is that it allows cross domain calls. For cross domain calls you should use either “jsonp” or make the Ajax calls in the same domain.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks for this Peter, but isn’t my webpage on http://leadmesh.cloudapp.net:8080 not on the same domain as my call to the server on http://leadmesh.cloudapp.net/Admin.svc/Elements?filterscount=0&groupscount=0&pagenum=0&pagesize=10&recordstartindex=0&recordendindex=18 ?
Thanks
Mark
Hi Mark,
I do not know how the browser recognizes that, because the port is different and you call a service. According to me, you should use “jsonp”.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comOkay thanks Peter – I will try jsonp and let you know what I find.
Thanks again
Mark
-
AuthorPosts
You must be logged in to reply to this topic.