01-09-2013 06:57 PM
Hi all,
This seems a silly question, but nothing works for me!
I have a site from where I want to download some data (it's jason, don't think that matters though). For testing purposes, I configured a vhost so that http://mysite.localhost/getData.php points to where I want to extract the data from.
In the config.xml I whitelist that domain:
<access uri="http://mysite.localhost" subdomains="true"> <feature id="blackberry.app" version="1.0.0.0" required="true"/> <feature id="blackberry.invoke" version="1.0.0.0" required="true"/> </access>
And then I try to access it like so:
var baseURL = 'http://mysite.localhost'; $.getJSON(baseURL + 'getData.php', function(data) { //do something with my data console.log(data); });
With the ripple emulator I get:
XMLHttpRequest cannot load http://mysite.localhost/getData.php. Origin http://localhost is not allowed by Access-Control-Allow-Origin.
When I deploy it anyways to the Blackberry 10 Dev Alpha Simulator, nothing happens. At least it doesn't show that not allowed screen.
Adding "--disable-web-security" to my Chrome shortcut also won't work. It says that command is not allowed since it affects stability and security.
What could be the issue? What can I do so it works in Ripple also and my life gets easier while I test my app?
Thank you..! Help is MUCH appreciated.
01-09-2013 11:21 PM
Ok, I got it to work within Ripple.
I added a header to allow for cross domain on the server.
However, now the problem lies on the simulator, specifically the $.getJSON() function.
What is going on? How do I solve it?
Thanks
01-10-2013 05:53 PM
01-10-2013 07:14 PM - edited 01-10-2013 07:15 PM
what you need to do, is add &Callback=? to the URL
And makesure you are setting the right DataType and use $.ajax instead of $.getJSON
if using $.ajax - you can specify the data Type like JSON or JSONP