这是错误信息:"XMLHttpRequest cannot load http://125.135.136.111/testApp/login.jsp. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8020' is therefore not allowed access."
因为第一次写web项目,不是很懂。。请各位指教,谢谢!
我想请问创建web项目时,是不是要设置服务器端口?怎么设置呢?默认的是http://127.0.0.1:8020这个端口,可不可以更改?
这是js中的代码:
$(function(){
$('#login_btn').click(function(){
var pwdRegex = /^\w{6,20}/; //密码正则
if($('#username').val() == ''){
window.alert("请输入用户名!");
$('#email').focus();
}else if($('#password').val() == ''){
window.alert("请输入密码!");
$('#password').focus();
}else if(!pwdRegex.test($('#password').val())){
window.alert("密码不正确!");
$('#password').focus();
}else{
window.alert("登录中...");
// 创建XMLHttpRequest对象
var xmlhttp;
if (window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
window.alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET", "http://125.138.147.111/testApp/login.jsp", true);
xmlhttp.send();
}
});
});