我正在尝试使用 easyXdm 库让跨域 AJAX 帖子工作。
在我的本地开发环境中,我有两个站点:
1. http://localhost/MySite/ws/easyXDM/cors/index.html(EasyXdm 文件) 2. http://localhost/MyClientSite/TestPage.html(来自这里的 AJAX 帖子)
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
并且应该在 *database 中创建一个记录。
注意:我正在替换我现有的 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