2013-03-27 101 views
3

我想获得跨域AJAX后使用easyXdm库工作。使用easyXdm跨域AJAX后

在我的本地开发环境,我有两个网站:

 
1. http://localhost/MySite/ws/easyXDM/cors/index.html (EasyXdm file) 
2. http://localhost/MyClientSite/TestPage.html (AJAX post from here) 

TestPage.html(AJAX邮报)

var rpc = new easyXDM.Rpc({ 
     remote: "http://localhost/MySite/ws/easyXDM/cors/index.html" 
    }, 
    { 
     remote: { 
      request: {} 
     } 
    }); 

rpc.request({ 
     url: "http://localhost/MySite/ws/MyService.asmx/DoSomething", 
     method: "POST", 
     data: jsonData 
    }, function(response) { 
     console.log(JSON.parse(response.data)); 

     $('#thanksDiv').fadeIn(2000, function() { 
      $('#thanksDiv').fadeOut(4000); 
     }); 
    }); 

当我做AJAX后我得到了我的浏览器下控制台:

easyXDM present on 'http://localhost/MySite/ws/easyXDM/cors/index.html?xdm_e=http%3A%2F%2Flocalhost%2FMyClientSite%2FTestPage.html&xdm_c=default884&xdm_p=4 
native JSON found 
easyXDM.Rpc: constructor 
{Private}: preparing transport stack 
{Private}: using parameters from query 
easyXDM.stack.SameOriginTransport: constructor 
easyXDM.stack.QueueBehavior: constructor 
easyXDM.stack.RpcBehavior: init 
{Private}: firing dom_onReady 
... deferred messages ... 
easyXDM.Rpc: constructor 
{Private}: preparing transport stack 
{Private}: using parameters from query 
easyXDM.stack.SameOriginTransport: constructor 
easyXDM.stack.QueueBehavior: constructor 
easyXDM.stack.RpcBehavior: init 
... end of deferred messages ... 
easyXDM.stack.SameOriginTransport: init 
easyXDM.stack.RpcBehavior: received request to execute method request using callback id 1 
easyXDM.stack.RpcBehavior: requested to execute procedure request 
easyXDM.stack.QueueBehavior: removing myself from the stack 

问题: Web服务从未实际接收数据。这很明显,因为我的AJAX发布成功函数应该显示一个thanksDiv并且还应该在*数据库中创建一条记录。

注:我正在更换现有的AJAX邮编,因为我需要使用easyXdm来解决客户端网站上Internet Explorer 6和7的问题。

附加信息: 的文件结构,其中我easyXdm文件位于如下:

/ws/easyXDM/easyXDM.debug.js 
/ws/easyXDM/easyXdm.swf 
/ws/easyXDM/json2.js 
/ws/easyXDM/name.html 
/ws/easyXDM/cors/index.html 
+0

存在已经与easyXDM工作这么几个人。你可以看看http://stackoverflow.com/questions/27203172/easyxdm-download-files-from-3rd-party-service吗? – 2014-11-29 22:35:48

+0

@V_B客户端和服务器都必须使用EasyXDM才能成功运行。 – Seany84 2014-11-30 13:57:53

回答

1

我的Web服务被扔一个HTTP 500服务器错误为jsonData不能被正确地通过easyXdm发送。

JSON数据看起来像这样它被张贴之前:

{ “参数1”: “值1”, “参数2”: “值2” ......}

但是,Web服务每行接收一个字符的数据,例如

{ 
" 
p 
a 
r 
a 
m 
" 
.... 

我没有序列化JSON数据之前,我的职位。因此,在原有基础上的代码,我贴在原来的问题:

得到它的工作我改了行

data: jsonData 

data: JSON.parse(jsonData)