为了账号安全,请及时绑定邮箱和手机立即绑定

为什么jQuery可以正常请求,angularjs却报跨域错误?

为什么jQuery可以正常请求,angularjs却报跨域错误?

慕工程0101907 2018-11-13 17:21:01
报 XMLHttpRequest cannot load http://example.com/v1/recharge. Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response.下面这个却可以, var data = {          'operator': {'user_id': '4320-9962-1b83f8fc4264', 'user_name': '乱石铺街'},          'amount': 1,          'recharge_amount': 2,          'currency': 'SGD',          'user': {'user_id': '4b92-ad75-506590099de5', 'user_name': 'ssdss'}        };        $.ajax({          url: 'example.com/v1/recharge',          method: 'POST',          dataType: 'json',          headers:{'Content-Type': 'application/json'},          data: JSON.stringify(data),          success: function (data) {            alert(JSON.stringify(data));          }        });           
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 574 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号