Hi Arief!

If I understood your question correctly, I think you will need to use the 
SystemXHR API[1] and permission[2] to accomplish that in general. This is due 
to (in this regard) your app is trying to access "external" content - that is, 
it is accessing cross-origin resources via XMLHttpRequest, which is (most of 
the time) forbidden. The SystemXHR permission and property lets your app 
execute XHR request without being limited by this origin-checking.

A possible workaround for the above problem might be (and quite a few 
websites/services who have publicly accessible API-s already do this) is to 
make requests to online resources which support the CORS scheme (Cross-origin 
resource sharing)[3], in which (if you have access to the server-side) you can 
control from which origins your "service" could be accessed, and thus queried 
by XHR also.

Hope to have answered your question, if not, feel free to elaborate.

Happy hacking!
Flaki

[1] 
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#Non-standard_properties
http://davidwalsh.name/forums/topic/firefox-os-systemxhr

[2] 
https://developer.mozilla.org/en-US/docs/Web/Apps/App_permissions#Hosted_app_and_privileged_app_permissions

[3] 
https://developer.mozilla.org/fr/docs/HTTP/Access_control_CORS#Access-Control-Allow-Origin


On Tuesday, May 28, 2013 8:41:58 AM UTC+2, Arief Bayu Purwanto wrote:
> Dear all,
> 
> 
> 
> I have question: How do I do AJAX (or http request) from packaged app?
> 
> I'm trying to build RSS reader.
> 
> 
> 
> I've tried using Jquery: $.ajax() request and got status=0, responseText =
> 
> null / error.
> 
> 
> 
> 
> 
> Thank you.
> 
> 
> 
> Note: if this is not the appropriate channel, please suggest me where
> 
> should I point this question to?
> 
> 
> 
> -- 
> 
> Best Regard,
> 
> http://about.me/ariefbayu

_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to