问题描述
本地测试没有问题,上到服务器(service 2003)ie不行了!$(document).ready(function(){$("#address").blur(function(){if($("#address").val().trim()==""){$("#addressInfo").html("x 详细地址不能为空!").css("color","red");}else{if($("#address").val().trim().length<5){$("#addressInfo").html("x 长度不能小于5个字符,请认真填写!").css("color","red");}else{$("#addressInfo").html("(具体地址填写)").css("color","blue");}}});$("#nameLogin").blur(function(){if($("#nameLogin").val().trim()==""){$("#loginInfo").html("账号不能为空!").css("color","red");}else{$("#loginInfo").html("");}});$("#passWordLogin").blur(function(){if($("#passWordLogin").val().trim()==""){$("#loginInfo").html("密码不能为空!").css("color","red");}else {$("#loginInfo").html("");}});$("#username").blur(function(){//获得输入框的数值var userName =$("#username").val().trim();// 清空提示框信息$("#userNameInfo").html("");if(userName==""){$("#userNameInfo").html("x 登录名不能为空");$("#userNameInfo").css("color","red").css("fontSize","10px").show("show",2);}else{var pattern = /^[A-Za-z0-9]{4,8}$/;if (!pattern.test(userName)) {$("#userNameInfo").html("× 登录名格式不正确");$("#userNameInfo").css("color", "red").css("fontSize","10px").show("slow",2);}else{$("#userNameInfo").html("√ 正确");$("#userNameInfo").css("color", "blue").css("fontSize","10px").show("slow",2);}}});$("#password").blur(function(){//获得输入框的数值var passWord =$("#password").val().trim();$("#passWordInfo").html("");if(passWord==""){$("#passWordInfo").html("x 密码不能为空");$("#passWordInfo").css("color","red").css("fontSize","10px").show("show",2);}else{var pattern = /^[A-Za-z0-9]{6,8}$/;if(!pattern.test(passWord)){$("#passWordInfo").html("× 密码格式不正确");$("#passWordInfo").css("color", "red").css("fontSize","10px").show("slow",2);}else{$("#passWordInfo").html("√ 正确");$("#passWordInfo").css("color", "blue").css("fontSize","10px").show("slow",2);}}});$("#passWord2").blur(function(){var passWord2 = $("#passWord2").val().trim();var passWord =$("#password").val().trim();$("#passWord2Info").html("");if(passWord2==""){$("#passWord2Info").html("x 密码不能为空");$("#passWord2Info").css("color","red").css("fontSize","10px").show("show",2);}else {$("#passWord2Info").html("");if(passWord!=passWord2){$("#passWord2Info").html("x 两次输入不一致");$("#passWord2Info").css("color","red").css("fontSize","10px").show("show",2);}else{$("#passWord2Info").html("√ 正确");$("#passWord2Info").css("color", "blue").css("fontSize","10px").show("slow",2);}}});$("#province").change(function(){$("#city").empty();var id = $(this).find("option:selected").attr("value");$.ajax({type: "GET",url: "/zone/city/"+id,success: function(data){$.each(data,function(i, o){$("#city").append("<option value='"+o.id+"'>"+o.name+"</option>");});}});});$("#province").change();$("#subBtn").click(function(){if(!checkForm())return false;var username = $("#username").val().trim();var password = $("#password").val().trim();var province = $("#province").val().trim();var city = $("#city").val();var sex = $("#sex").val();submitForm(username, password, province, city, sex);});});//定义方法--验证是否为空function isNull(ele) {var _form = document.searchForm;if (_form[ele].value == "") {_form[ele].focus();return true;}return false;}function checkForm(){var _form = document.searchForm;if (isNull("username")) {$("#userNameInfo").html("x 登录名不能为空").css("color", "red").css("fontSize","10px").show("slow",2);_form.name.focus();return false;}else if($("#username").val().trim().length<4){$("#userNameInfo").html("x 登录名长度不能小于4个字符");_form.name.focus();return false;}if (isNull("password")) {$("#passWordInfo").html("x 登录密码不能为空").css("color", "red").css("fontSize","10px").show("slow",2);_form.password.focus();return false;}if (isNull("password2")) {$("#passWord2Info").html("x 确认密码不能为空!").css("color", "red").css("fontSize","10px").show("slow",2);_form.password2.focus();return false;}if(_form.password.value!=_form.password2.value){$("#passWord2Info").html("x 您两次输入的密码不一致,请重新输入!").css("color", "red").css("fontSize","10px").show("slow",2);alert("");_form.password2.focus();return false;}if (isNull("checkcode")) {$("#checkCodeInfo").html("x 验证码不能为空!").css("color", "red").css("fontSize","10px").show("slow",2);_form.checkcode.focus();return false;}if( !Utils.checkCode($("#checkcode").val()) ){$("#checkCodeInfo").html("x 验证码错误!").css("color", "red").css("fontSize","10px").show("slow",2);return false;}if ($("#service").attr("checked")!="checked") {$("#serviceInfo").html("x 请仔细阅读并同意用户服务协议并同意再注册!").css("color", "red").css("fontSize","10px").show("slow",2);return false;}else{$("#serviceInfo").html("√ 正确").css("color", "blue").css("fontSize","10px").show("slow",2);}return true;}var submitForm = function(username, password, province, city, sex){$.ajax({type: "POST",url: "/reg/create",data:{"username":username,"password":password,"province":province,"city":city,"sex":sex},success: function(data){alert(data.message);if(data.status){if(window.parent)window.parent.location.reload();elsewindow.location.reload();}}});};
解决方案
本地可以,服务器上不可以,这种通常都是路径问题,比如引用...url: "/zone/city/"+id, ...本体可能是http://localhost:8080/myapp/这样,而服务器可能是http://myapp/这样,那么上述路径基本就废掉了。。。
解决方案二:
浏览器兼容性已经测试过。那和服务器的IE就没什么关系了,剩下的,只有是服务器端的问题。而且很有可能是js的路径问题,我建议你用firebug查看一下,是否所有的js和css文件都已经正确的获取到!
解决方案三:
可以考虑将本地vhost配置文件里配置上服务器的域名(如127.0.0.1 www.xxxx.com),本机模拟线上环境,然后尝试下访问该页(如http://www.xxx.com/test/test.jsp),看下问题是否依然存在,估计跟服务器没啥太大关系,大多数跟目录引用有关吧。