这是我的代码。这是使用json到jsoncall.php文件的传递值,需要得到响应。
var url = 'jsoncall.php';
var calltype = "signin";
parameters = 'call='+calltype;
var email = document.getElementById('email').value;
var pass = document.getElementById('password').value;
var serverurl = document.getElementById('s_url').value;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(email == "") {
alert("Plese enter your email address!");
return false;
}else if(email != ""){
if(reg.test(email) == false) {
alert('Invalid Email Address!');
return false;
}
}else if(pass == "") {
alert('Please enter your password!');
return false;
}
setTimeout( function() {
jQuery.getJSON(serverurl+url+'?callback=?',
{call:calltype, txtEmail: email, txtPassword: pass, login: ""},
function(data) {
console.log(data);
//alert(data.result);
if(data.result == 0){
alert("Invalid email or password!");
return false;
}else {
window.location = data.result;
}
});
}, 100);
这项工作在Crome,Firefox。但这在IE中不起作用。当我按下f12并在IE中获得开发者工具时,它开始在IE中工作。否则它将无法工作。谢谢你的帮助。
答案 0 :(得分:1)
这是因为console.log
仅在您启动开发人员工具后才可用。您可以使用try / catch块吸收错误,或者创建一个虚拟console
对象(如果它不存在)。
答案 1 :(得分:1)
评论第console.log
行,它会起作用。最好在alert
中使用IE
。但是,如果您想使用console
,请参阅此http://www.we-are-gurus.com/blog/1578-avoid-console-log-error-with-ie