以下是JavaScript,要调用ajax函数,$ ajax在firefox中不起作用,但在chrome中起作用。 ajax在firefox浏览器中未收到响应。
function ajaxAsyncRequest(){
alert("ajaxAsyncRequest function");
var tempValUrl = $(".urlVal").val();
var url = tempValUrl + 'DepartmentUser/departmentUserTokenReceive';
alert("url=="+url);
$.ajax({
url : url,
method : 'GET',
contentType : "application/json",
dataType : "json",
success : function(response) {
alert(response);
var obj = response;
alert(obj);
alert("keyType" + obj.keyType);
if (obj.keyType == "sign") {
document.getElementById("signName").value = obj.name;
document.getElementById("certNumber").value = obj.serialNumber;
document.getElementById("signCa").value = obj.issuer;
document.getElementById("signExpiryDate").value = obj.tempDateTime;
document.getElementById("signPublicKey").value = obj.publicKey;
}
if (obj.keyType == "cipher") {
document.getElementById("cipherName").value = obj.name;
document.getElementById("cipherCertNumber").value = obj.serialNumber;
document.getElementById("cipherCa").value = obj.issuer;
document.getElementById("cipherExpiryDate").value = obj.tempDateTime;
document.getElementById("cipherPublicKey").value = obj.publicKey;
}
}
});
}
答案 0 :(得分:0)
您必须将event定义为事件处理程序的参数:-
event.preventDefault();