【发布时间】:2013-08-03 15:58:28
【问题描述】:
我是 ajax 开发的新手,我正在尝试使用 xhr 来获取和发布数据,问题是当我使用基于端口的请求时?
这是我的工作代码,而不是工作代码
$.ajax({
url : "login.php",
type : "post",
data : {
userProfile : JSON.stringify(data)
},
success : handleDBResponse,
error : function(jqXHR, textStatus,errorThrown) {
console.log("The following error occured: "+ textStatus,errorThrown);
},
complete : function() {
// console.log("user authentication
// successful.")
}
});
这很好用,但是当我使用带有 url:port 的原生 xhr 时没有响应。
function reqListener () {
console.log(this.responseText);
};
var oReq = new XMLHttpRequest();
oReq.onload = reqListener;
oReq.open("get", "http://www.domain.com:443/akorp.css", true);
oReq.send();
它不起作用,我被调试了,我发现请求状态被取消了。
.htaccess 包含文件
Access-Control-Allow-Origin:*
我仍然收到错误
www.domain.com:443 not allowed by www.domain.com Access-Control-Allow-Origin etc..
此错误的可能原因是什么以及如何正确地将请求发送到端口?
【问题讨论】:
标签: ajax html jquery xmlhttprequest cors