我有以下代码:
$.ajax({
type: 'POST',
url: 'mylink.com/coupon2.php',
crossDomain: true,
data: '{"some":"json"}',
dataType: 'json',
success: function(responseData, textStatus, jqXHR) {
//$( "#coupon_code" ).html("Coupon code: " + responseData.data.code);
//var value = responseData;
//var json = JSON.parse(responseData);
$( "#coupon_code" ).html("Coupon code: " + responseData.data);
},
error: function (responseData, textStatus, errorThrown) {
$( "#coupon_code" ).html( 'POST failed. ' + errorThrown + ', ' + responseData );
}
});它在Windows上的Chrome和Firefox中运行得很好,但在OS上不发布或随后返回Chrome。为什么会这样?
发布于 2016-02-06 20:39:36
这个问题不是浏览器或操作系统特有的,而是严格地与试图从安全连接到不安全连接的跨源请求有关。在Windows上测试代码时,我没有通过https连接到初始站点。然而,当我在Mac上测试它时,我通过https连接到初始站点,并试图发布到一个非https url。这就是为什么post在PC上运行,随后在Mac上失败的原因。
https://stackoverflow.com/questions/35242563
复制相似问题