获取URL参数(支持中文)
function getQueryString(name) {
let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
let r = window.location.search.substr(1).match(reg);
if (r != null) {
return decodeURIComponent(r[2]);
};
return null;
}
JQuery请求JSON
function queryJson(url, successful, fail, error) {
$.ajax({
type: "GET",
url: url,
dataType: "json",
success: function (json) {
if ("code" in json && "noerror" != json.code) {
if (null != fail) {
fail(json);
}
}
else {
if (null != successful) {
successful(json);
}
}
},
error: function (jqxhr, textStatus, errorThrown) {
if (null != error) {
error(textStatus);
}
}
});
}
JQuery请求TEXT
function queryText(url, successful, fail, error) {
$.ajax({
type: "GET",
url: url,
dataType: "text",
success: function (res) {
if ("" == res) {
if (null != fail) {
fail(res);
}
}
else {
if (null == successful) {
successful(res);
}
}
},
error: function (jqxhr, textStatus, errorThrown) {
if (null != error) {
error(textStatus);
}
}
});
}
判断是不是为空字符串
function isNull(val) {
return null == val || undefined == val || "undefined" == val || "" == val;
}