jquery的ajax不能在Facebook应用程序中工作 [英] jquery's ajax not working in facebook apps

查看:151
本文介绍了jquery的ajax不能在Facebook应用程序中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个Facebook应用程序,一切正常,除了我正在使用的ajax部分从第一个选择框中选择的项目填充第二个框。



我正在使用jquery(v1.3.2)来完成这个。这个ajax在主机上工作得很好,我已经占用了空间,但是它在Facebook上不起作用。



这是我关于这个问题的问题, / p>


  • 画布页面的url需要与我的应用程序名称相同。 (在我的情况下是不同的)



我在facebook的父选择框的onchange事件上收到此错误。 >


访问受限URI拒绝代码:1012





  • 什么可能是错的?请帮我解决这个问题。



谢谢

解决方案

您不允许从脚本运行的域请求其他站点的数据。例如,如果您正在运行脚本www.example.com/script.js,那么您只能在www.exaple.com域下的ajax文件,而不是www.facebook.com。



有几种方法可以实现:




  • JSONp 是一种方式,但它要求
    Facebook回复jsonp数据。不是
    肯定如果它。关于JSONp的更多信息 here

  • CSSHttpRequest (或AJACSS)是另一种方式。严重怀疑facbook使用这种方法。


I am trying to create a facebook application, all is working fine except the ajax part that I am using to populate a second box from the item selected in first select box.

I am using jquery (v1.3.2) for accomplishing this. This ajax is working absolutely fine on the host where I have taken space for it, but it is not working in facebook.

Here are my questions regarding to this problem,

  • does canvas page url needs to be same as that of my application name. ( in my case it is different)

I am getting this error on the onchange event of parent select box inside facebook.

Access to restricted URI denied" code: "1012

  • what might be wrong...? Please help me solve this problem.

Thanks

解决方案

You are not allowed to request data from other sites than the domain the script is running on. For example, if you are running the script www.example.com/script.js, then you can only ajax files under the www.exaple.com domain, not www.facebook.com.

There are a few ways to do it:

  • JSONp is a way, but it requires that facebook replies with jsonp data. Not sure if it does. More info on JSONp here.
  • CSSHttpRequest (or AJACSS) is another way. Seriously doubt facbook uses this method.

这篇关于jquery的ajax不能在Facebook应用程序中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆