在 iframe 黑莓 5 中接收 json
您好,我正在尝试从 iframe 上传图像并且正在工作,但无法从服务器获得响应,我尝试将表单的目标设置为 _blank,并且出现保存文件而不是将其显示为的提示尝试打开保存的文件时,黑莓会警告“可以显示文件”,但如果我通过蓝牙发送文件并在 mi pc 中打开它,它将具有有效的服务器响应,我认为这是阻止该文件的 mime 类型要加载的 iframe但我不知道我是否正确,
这是服务器返回的标头:
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Type:application/json
Date:Fri, 24 Feb 2012 00:31:06 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=15, max=61
Pragma:no-cache
Server:Apache/1.3.42 (Unix) mod_jk/1.2.30 mod_gzip/1.3.26.1a mod_log_bytes/1.2 mod_bwlimited/1.4 mod_ssl/2.8.31 OpenSSL/0.9.8e-fips-rhel5
Transfer-Encoding:chunked
X-Powered-By:PHP/5.2.17
我从桌面 Chrome 获取标头,
我在几个小时后进行修复此问题,但我不知道如何解决此问题任何帮助将不胜感激,谢谢
更新 我尝试了 mime 类型的东西,我可以重现将 json mime 类型设置为任意文档的问题,并使用此代码
<?php header('Content-type: application/json'); ?>
,并且正如预期的那样,我在黑莓上收到“culd no load”警报,有什么方法可以强制它显示json 作为纯文本以便我稍后可以解析它?
hi i'm trying to upload a image from an iframe and is working, but cant get the response from the server, i try to set the target of the form to _blank and i get an promp to save the file instead of displaying it as html or plain txt when trying to open the saved file blackberry alerts "can display file" but if i send the file over Bluetooth and open it in mi pc it have the valid server response,i think that is the mime types that are preventing the iframe to load but i don't know if i'm correct
this are the header that the server return:
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Type:application/json
Date:Fri, 24 Feb 2012 00:31:06 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=15, max=61
Pragma:no-cache
Server:Apache/1.3.42 (Unix) mod_jk/1.2.30 mod_gzip/1.3.26.1a mod_log_bytes/1.2 mod_bwlimited/1.4 mod_ssl/2.8.31 OpenSSL/0.9.8e-fips-rhel5
Transfer-Encoding:chunked
X-Powered-By:PHP/5.2.17
i get the header from a desktop chrome
i'm doing after hours to get this fixed but i can´t figure out how to work around this any help will be appreciated thanks
update
i try the mime type stuff and i can reproduce the problem seting the json mime type to an arbitrary document whit this code
<?php header('Content-type: application/json'); ?>
and as spected i get de "culd no load" alert on blackberry, is there any way i can force it to show the json as plain text so i can later parse it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能为时已晚,无法帮助您,但也许这会对其他人有所帮助...
本质上,当您将文本发送回空 iframe 时,浏览器会查看传入的数据,如果它不是 HTML,它们会在其周围包装标签。
如果将标头更改为 content-type: text/html,浏览器将不会使用 html 填充 iframe,并且您将获得原始 json。
Probably too late to help you out but maybe this will help someone else...
Essentially when you send text back to an empty iframe, the browsers are looking at the incomming data and if its not HTML they're wrapping tags around it.
If you change your header to content-type: text/html the browsers will not populate the iframe with html and you get the raw json.