[英]Returning json from php to dashcode web application
I am building a search result page that needs to be formatted for the iPhone. 我正在建立一个需要为iPhone格式化的搜索结果页面。 I have built a browser based web application in Dashcode and input data from a php file.
我已经在Dashcode中构建了一个基于浏览器的Web应用程序,并从php文件输入了数据。 For this example I will call the php file test.php.
对于此示例,我将调用php文件test.php。 Here is the basic model.
这是基本模型。 (the i= is the query for the php)
(i =是对php的查询)
web app sends i= --------> test.php --------> mysqldatabase Web应用程序发送i = --------> test.php --------> mysqldatabase
then 然后
mysqldatabase ---------> test.php ----------> JSON output mysqldatabase ---------> test.php ----------> JSON输出
then 然后
JSON output ------> Dashcode Browser Graphical UI JSON输出------> Dashcode浏览器图形UI
The data is getting encoded, but not loading into Dashcode's browser UI. 数据已被编码,但未加载到Dashcode的浏览器UI中。 Ideas?
有想法吗?
It's probably the same-origin policy. 这可能是同源政策。 Under "Run & Share" enter the domain hosting your PHP file in the "Simulate running on domain:" field (and check the checkbox next to it).
在“运行并共享”下,在“模拟在域上运行:”字段中输入托管PHP文件的域(并选中其旁边的复选框)。
If you want to go "cross-domain" while testing within dashcode… this proxy.php
snippet allows you to enter a URL such as… http://myprivatedomain.com/proxy.php?url=https://some.twitter.jsonapi.url%8483948
and use it all, without whining, from DashCode…. 如果要在
proxy.php
代码内进行测试时进行“跨域”访问,则此proxy.php
代码段可让您输入URL,例如…… http://myprivatedomain.com/proxy.php?url=https://some.twitter.jsonapi.url%8483948
//myprivatedomain.com/proxy.php? proxy.php
https: proxy.php
http://myprivatedomain.com/proxy.php?url=https://some.twitter.jsonapi.url%8483948
并通过http://myprivatedomain.com/proxy.php?url=https://some.twitter.jsonapi.url%8483948
使用所有内容,而无需抱怨。
<?php $filename = $_REQUEST['url'];
header('Content-Type: application/json');
ob_start();
json_encode(readfile($filename));
ob_flush(); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.