Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XMLHttpRequest and cross domain request

152 views
Skip to first unread message

Daniel Neis Araujo

unread,
Aug 6, 2013, 8:13:49 PM8/6/13
to dev...@lists.mozilla.org
Hello,

sorry if this has been discussed before but i've found no references in my
searches.

I work with Moodle, an open-source learning management system, for some
time and they have a pretty good mobile app that works on android and ios.
It's already a "webapp" (https://github.com/moodlehq/moodlemobile) based on
jquery, phonegap etc.
So i think it should be easy to port it to firefox os and start working on
it.
I've write a sample manifest file, added it to the app root folder and got
it on firefox os simulator running as a packaged app. The first screen
shows well, but then i've faced the problem.
This application ask me which Moodle site i want to visit, so i insert the
URL, my username and password and it should use the webservices to get to
the site and bring me the contents. But, with a packaged application i just
can't do it, because it is considered a cross domain request and altough i
can see in debugger and wireshark that my "POST" was submitted and server
responded correctly with 200 OK, the requests fails and fires the "onerror"
event. I've tested this with the Boiler Plate app (
https://github.com/robnyman/Firefox-OS-Boilerplate-App) and it fails too.
These apps also fail on my keon (running latest 1.1 stable from geeksphone
on it).
If i install the application as hosted from the same site i am serving
Moodle, it works ok, but then i would have to have one app for each Moodle
i have access to, and it is not really nice.
So, i would appreciate any advices on how to get this app working =)

Kind regards,

--
Daniel Neis Araujo

pzhang

unread,
Aug 6, 2013, 10:44:20 PM8/6/13
to Daniel Neis Araujo, dev...@lists.mozilla.org
Hi Daniel,

I think you need to add 'systemXHR' permission to your app manifest,
here is the permission list:
https://developer.mozilla.org/en-US/docs/Web/Apps/App_permissions

----
Pin Zhang (??)
+86-13811800051
Sent from Firefox <http://firefox.com.cn>

Daniel Neis Araujo

unread,
Aug 7, 2013, 5:11:21 AM8/7/13
to pzhang, dev...@lists.mozilla.org
Hello,

thanks for help. It worked on Boilerplate app that uses XMLHTTPRequest, but
didn't work for Moodle's app that uses jquery's $.ajax function.
Any thoughts?

Kind regards,
Daniel


On Tue, Aug 6, 2013 at 11:44 PM, pzhang <pzh...@mozilla.com> wrote:

> Hi Daniel,
>
> I think you need to add 'systemXHR' permission to your app manifest,
> here is the permission list:
> https://developer.mozilla.org/en-US/docs/Web/Apps/App_permissions
>
> ----
> Pin Zhang (张频)
> +86-13811800051
> Sent from Firefox <http://firefox.com.cn>
> On 2013年08月07日 08:13, Daniel Neis Araujo wrote:
>
> Hello,
>
> sorry if this has been discussed before but i've found no references in my
> searches.
>
> I work with Moodle, an open-source learning management system, for some
> time and they have a pretty good mobile app that works on android and ios.
> It's already a "webapp" (https://github.com/moodlehq/moodlemobile) based on
> jquery, phonegap etc.
> So i think it should be easy to port it to firefox os and start working on
> it.
> I've write a sample manifest file, added it to the app root folder and got
> it on firefox os simulator running as a packaged app. The first screen
> shows well, but then i've faced the problem.
> This application ask me which Moodle site i want to visit, so i insert the
> URL, my username and password and it should use the webservices to get to
> the site and bring me the contents. But, with a packaged application i just
> can't do it, because it is considered a cross domain request and altough i
> can see in debugger and wireshark that my "POST" was submitted and server
> responded correctly with 200 OK, the requests fails and fires the "onerror"
> event. I've tested this with the Boiler Plate app (https://github.com/robnyman/Firefox-OS-Boilerplate-App) and it fails too.
> These apps also fail on my keon (running latest 1.1 stable from geeksphone
> on it).
> If i install the application as hosted from the same site i am serving
> Moodle, it works ok, but then i would have to have one app for each Moodle
> i have access to, and it is not really nice.
> So, i would appreciate any advices on how to get this app working =)
>
> Kind regards,
>
>
>
>


--
Daniel Neis Araujo

Lucas Adamski

unread,
Aug 7, 2013, 6:12:33 AM8/7/13
to Daniel Neis Araujo, pzhang, dev...@lists.mozilla.org
Have you tried:

$.support.cors = true;

http://api.jquery.com/jQuery.support/
> _______________________________________________
> dev-b2g mailing list
> dev...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-b2g

Daniel Neis Araujo

unread,
Aug 7, 2013, 1:50:31 PM8/7/13
to Lucas Adamski, pzhang, dev...@lists.mozilla.org
Hello,

i've tried your suggestion about cors but it fails the same way.
Here is the manifest i am using:

{
"name": "Moodle Mobile",
"launch_path": "index.html",
"description": "Moodle Mobile App",
"type": "privileged",
"icons": {
"128": "/img/icon/android/icon-36-ldpi.png"
},
"developer": {
"name": "Moodle.org",
"url": "http://www.moodle.org"
},
"installs_allowed_from": ["*"],
"default_locale": "en",
"permissions": {
"systemXHR": {}
--
Daniel Neis Araujo

Jay Lonnquist

unread,
Aug 9, 2013, 3:31:18 AM8/9/13
to
I've never been able to get this to function with the above cited methods, in the Firefox OS simulator (can't comment on an actual phone, as I have no access to one at the present time).

As a workaround I employ the following plugin:

http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/
0 new messages