简体   繁体   English

小部件跨域Ajax调用

[英]Widget cross domain ajax call

We have a widget for clients to put onto their website. 我们有一个小部件供客户放到他们的网站上。 This widget needs to make a call to our website to validate some data entered by the user. 该小部件需要致电我们的网站,以验证用户输入的某些数据。 However, ajax calls are domain bound, so calling from the clients webpage to our webpage is not allowed. 但是,ajax调用是受域限制的,因此不允许从客户端网页调用我们的网页。

How can i make a request from any site to my own? 如何从任何站点向自己的站点发出请求?

There is a way, i'm sure. 我敢肯定有办法。 For example, Facebook, with it's user hosted like button, probably also makes a request to their own website. 例如,Facebook,其用户像按钮一样被托管,可能还会向自己的网站发出请求。

EDIT 编辑

i am using XMLHTTP for this 我为此使用XMLHTTP

Without enabling any options on the client website. 在客户端网站上未启用任何选项。

Try setting your data type to 'jsonp', as seen in this answer . 尝试将数据类型设置为'jsonp',如本答案所示 Although that answer is in jQuery, it is still possible , although slightly more difficult. 尽管这个答案在jQuery中,但仍然有可能 ,尽管难度稍大一些。 I don't want to be one of "those guys", but in this case it's easier to use jQuery. 我不想成为“那些家伙”之一,但是在这种情况下,使用jQuery更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM