2011-05-27 37 views
0

我正在使用easyXDM來促進網站與位於iframe中並託管在我的域中的購物車之間的通信。當用戶將某物添加到購物車時,我使用easyXDM.Rpc將物品信息發送到iframe購物車。到目前爲止這麼好,但現在我想從我的域上的iframe購物車中調用一個ajax請求來查找該項目並返回價格。我無法作出任何形式的Ajax調用,這是我使用的代碼:使用easyXDM的iframe中的Ajax請求

在一個網站上的另一個域(消費者):

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購物車託管我的域名(供應商):

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: {} 
    } 
}); 

回答