b***@vip.qq.com
b***@vip.qq.com
  • 发布:2016-05-26 14:54
  • 更新:2016-05-26 15:46
  • 阅读:1452

mui.ajax 跨域以及传参问题

分类:MUI

js代码:
mui.ready(function() {
mui.ajax('http://127.0.0.1:57419/service/Ios/Finance.ashx', {
data: {
'busType': '3',
'userCode': userCode,
'passwor': password,
'appCode': businessCode,
'preMonth': preMonth
},
dataType: 'json',
type: 'post',
contentType: "application/x-www-form-urlencoded; charset=utf-8",
timeout: 60000,
success: function(data, status, xhr) {
mui.alert("success");
},
error: function(xhr, type, errorThrown) {
//异常处理;
console.log(type+"; xhr:"+xhr.responseText);
mui.toast("未响应后台返回的数据!", "错误提示", "确定", null);
}
});
})
1.在PC端调试一直报错:[Web浏览器] "XMLHttpRequest cannot load http://127.0.0.1:57419/service/Ios/Finance.ashx. No 'Access-Control-Allow-Origin' header is present on the requested resource.
2.能进入后台方法,但是返回结果后。ajax中的success方法一直没有执行。
3.其次:用GET方法能传参到后台,POST却不行。
后台代码:
public void ProcessRequest(HttpContext context)
{
…………
context.Response.Write(JsonHelper.ToJson(hash));
context.Response.End();
}
求大牛指教,困扰一天了。

2016-05-26 14:54 负责人:无 分享
已邀请:
b***@163.com

b***@163.com

跨域请求是不允许的,你可以用真机或模拟器测试

b***@vip.qq.com

b***@vip.qq.com (作者)

试用了下,jquery的ajax post可以传参!但依然遇到那个类似跨域的问题,结果始终返回不过来,success依旧不执行。

该问题目前已经被锁定, 无法添加新回复