報 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)); } });
為什么jQuery可以正常請求,angularjs卻報跨域錯誤?
慕工程0101907
2018-11-13 17:21:01