0

I have a GWT app and I'm using RequestBuilder get GET some json from a php script I have running on a Fatcow.com server. It returns the json just fine in the browser and returns a 200 status in Charles web debug proxy, but in the GWT app it always says the response status is 0 and doesn't give me any json. When I test my code on a known working URL, it returns 200 and I get the json I expect. Also, I already have header('Content-Type: application/json; charset=utf-8'); in my php, which I know is a common error. Is there any reason this would not be working? Is it a php thing, or am I doing something wrong?

1 Answer 1

1

You're hitting the Same-Origin Policy.

CORS is supported in most recent browsers (exceptions: IE and Opera; will be coming in IE 10 and Opera 12 respectively).

Only viable alternatives are JSONP (using JsonpRequestBuilder in GWT) or a "proxy" on the same server serving your GWT app.

Sign up to request clarification or add additional context in comments.

7 Comments

I'm running the GWT app from Eclipse and I'm accessing the php file online from my web server. acumeta.coryschulz.com/uibuilder/data/stocks.php So they're not from the same machine.
Yes, that's what I said: you're hitting the Same-Origin Policy. If you intend to ultimately deploy on the same machine, then you can try that instead: Using my own server in development mode instead of GWT's built-in Jetty instance
Yup, sorry, I misunderstood what SOP was. Is there a way that I can directly load a .json file such as www.coryschulz.com/data.json ? I've tried using jsonpRequestbuilder and it keeps on failing. What I'm trying to do is find a way to load some test data into a GWT app directly from a .json file. That wasn't working, so then I tried php instead.
Put your JSON file in your war directory.
Yeah, I've tried that too. Still fails. You would think GWT would have some easy way to load test data in directly from a json file, but I haven't found any tutorials on it.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.