i trying get a json variable from php to foreUI and dosen’t work, i put my jsonvariable online (http://www.gdsautomacao.com.br/jsonte…) if anyone know how i supost to do that, please help.
thanks
2 answers
Hello Guilherme,
The problem is that your PHP script implements JSON API instead of JSONP API.
“The difference between JSONP and JSON is that, JSONP will wrap the JSON data as a function call, while the function name is passed in from the request URL. Calling JSONP API is usually used to workaround the “The Same Origin Policy” and get JSON data from different servers. You can find a lot of information about these via Google.”
The sentence above is taken from http://www.foreui.com/blog/?p=1323, you can read it if you want to learn more.
If the PHP script is implemented by you, you can easily change it to JSONP. Just output json value with a callback function, like this:
echo $_GET[“callback”].”({‘var’:’26.4′});”;
After doing this, if you visit http://www.gdsautomacao.com.br/jsonte…, you will get:
({“var”:”26.4″});
If you visit http://www.gdsautomacao.com.br/jsonte…, you will get:
aaa({“var”:”26.4″});
Then you can use “Get JSON Object” action to call your PHP script.
This question is now closed