I am consuming service of random.org, (I want to get the numbers from random.org site using url). I am fetching data using ajax from my JavaScript. So how to make cross domain ajax call from my domain (and avoid permission error)? I want solution without help of server side code (sever proxy). Example code will be great help for me.
我正在使用random.org的服务,(我想使用url从random.org网站获取数据)。我从我的JavaScript中使用ajax获取数据。那么如何从我的域中进行跨域ajax调用(并避免权限错误)?我希望解决方案没有服务器端代码(服务器代理)的帮助。示例代码对我很有帮助。
3 个解决方案
#1
Lobby the owner of random.org to provide a jsonp API - that's the only way to make this happen.
大概使用random.org的所有者来提供jsonp API - 这是实现这一目标的唯一方法。
#2
Just sent an email to random.org and received this reply
刚刚发送电子邮件至random.org并收到此回复
Thanks for your email. Yes, I am working on a JSONP interface.
谢谢你的电邮。是的,我正在研究JSONP界面。
Best regards,
Mads
#3
You need a server proxy on your domain, or it won't happen. Here's a summary of cross-domain ajax techniques, the only 'real' non-proxy solution, as RichieHindle pointed out, being jsonp. But that requires you to be buddies with the guys at random.org, or for them to have a compelling reason to enable it for you.
您需要在您的域上使用服务器代理,否则它将不会发生。以下是跨域ajax技术的总结,这是唯一的“真正的”非代理解决方案,正如RichieHindle指出的那样,是jsonp。但这要求你在random.org与他们成为朋友,或者让他们有一个令人信服的理由为你启用它。
#1
Lobby the owner of random.org to provide a jsonp API - that's the only way to make this happen.
大概使用random.org的所有者来提供jsonp API - 这是实现这一目标的唯一方法。
#2
Just sent an email to random.org and received this reply
刚刚发送电子邮件至random.org并收到此回复
Thanks for your email. Yes, I am working on a JSONP interface.
谢谢你的电邮。是的,我正在研究JSONP界面。
Best regards,
Mads
#3
You need a server proxy on your domain, or it won't happen. Here's a summary of cross-domain ajax techniques, the only 'real' non-proxy solution, as RichieHindle pointed out, being jsonp. But that requires you to be buddies with the guys at random.org, or for them to have a compelling reason to enable it for you.
您需要在您的域上使用服务器代理,否则它将不会发生。以下是跨域ajax技术的总结,这是唯一的“真正的”非代理解决方案,正如RichieHindle指出的那样,是jsonp。但这要求你在random.org与他们成为朋友,或者让他们有一个令人信服的理由为你启用它。