我正在开发一个项目,我正在使用jQuery更改显示的数据。 jQuery函数调用控制器,它返回结果并相应地更改数据。这适用于Firefox,但不适用于webkit浏览器。代码如下:
function PageMethod(fn, paramArray, successFn, errorFn, strdt, ty) {
var dt;
var ct;
var typ;
if (ty != '' && typeof (ty) != 'undefined') {
typ = ty;
} else {
typ = "post";
}
if (strdt != '' && typeof (strdt) != 'undefined') {
dt = strdt;
ct = "text/html; charset=utf-8";
} else {
dt = 'json';
ct = "application/json; charset=utf-8";
}
var paramList = '';
if (paramArray.length > 0) {
for (var i = 0; i < paramArray.length; i += 2) {
if (paramList.length > 0) paramList += ',';
paramList += '"' + paramArray[i] + '":"' + paramArray[i + 1] + '"';
}
}
paramList = '{' + paramList + '}';
$.ajax({
type: typ,
url: fn,
contentType: ct,
data: paramList,
dataType: dt,
success: successFn,
error: errorFn
});
}
$("#btn").on('click', function (e) {
call();
}
function(){
PageMethod(basedir + "userjoined",
call_s,
AjaxFailed);
}
function call_s(r){
$("#div").html("<span>" +r + " </span>");
}
它适用于Firefox,但不适用于其他浏览器。请帮忙。