jquery ajax请求无效!

山城忙碌人 山城忙碌人 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
问题描述:
1:由于用户不想在浏览器中输入IP+端口号+应用名字 如:(http://127.0.0.1:8080/test),用户的想使用域名直接访问项目,如:(http://www.baidu.com),所以我使用nginx进行转换!
2:ng配置如下:
server {
listen 80;
server_name 127.0.0.1,www.baidu.com;
location / {
proxy_pass http://127.0.0.1:8080/test/;
proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header Host $host;
}

}
3:现在通过域名能直接访问项目,但登陆的时候,使用了jquery的ajax,使用nginx跳转后,jquery的ajax无法正常访问到后台程序,请问这是什么原因?
$("#btnLogin").click(function(){ 
$.ajax({
url : "/test/user.do?method=userLogin",
type : "post",
dataType: "text",
data : {
u_loginid : $("#u_loginid").val(),
u_password : $("#u_password").val(),
code : $("#code").val()
},success : function(data) {
var result = jQuery.parseJSON(data);
if (result.success == true) {
document.location.href = "/test/demo/main.jsp";
} else { $("#imgRead").attr("src","/yx/VerificationCode?time=" + new Date().getTime());

}
}
});
});



4:除了使用nginx,来实现直接访问域名,跳转到实际项目外,还有其它什么办法来实现跳转的需求?如:(访问http://www.baidu.com,直接跳转到http://127.0.0.1:8080/text)
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
山城忙碌人
Ajax 52,778 成员 25,334 内容