首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用easyXDM的iframe中的Ajax请求

使用easyXDM的iframe中的Ajax请求
EN

Stack Overflow用户
提问于 2011-05-27 12:44:31
回答 1查看 2.2K关注 0票数 0

我正在使用easyXDM来促进网站和购物车之间的通信,该购物车在iframe中并托管在我的域中。当用户向购物车添加商品时,我使用easyXDM.Rpc将商品信息发送到iframe购物车。到目前为止一切都很好,但现在我想从我的域上的iframe购物车中调用一个ajax请求来查找商品并返回价格。我无法进行任何类型的ajax调用,这是我使用的代码:

在另一个域(消费者)上的网站上:

代码语言:javascript
复制
var rpc= new easyXDM.Rpc({
        remote: remote_path,
        onReady: function(){
        },
        container: document.getElementById("cart"),
        props: {
            style: {
                border: "2px solid red",
                width: "200px",
                height: "300px"
            }
        }
    }, 
    remote: {
      fooBar: {}
    }

    //this submits the item info to add it to the cart
    $("#item_form").submit(function(){                               
      data = $("#menu_form").serialize();
      rpc.fooBar($(this).serialize());   
      return false;
    });

然后在我的域(提供商)上托管的iframe购物车中:

代码语言:javascript
复制
var rpc = new easyXDM.Rpc({}, {
    local: {
        fooBar: function(data){
            //alert(data) works to show the item information and this is where I would like to make an ajax call with this info, something like:
            //$.get(add_to_cart_path, function(data){})                
            //rpc.post(add_to_cart_path, "this is a test")
        }
    },
    remote: {
        barFoo: {}
    }
});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-27 16:18:48

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6147927

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档