$.get $.义齿
732 ワード
.get.postはbasePathを自動的に追加し、jQueryを書き換える方法
basePathの取得
get postを書き換える
basePathの取得
get postを書き換える
/**
* $.get $.post basePath
* [email protected]
*/
jQuery.each(["get", "post"], function (i, method) {
jQuery[method] = function (url, data, callback, type) {
if (jQuery.isFunction(data)) {
type = type || callback;
callback = data;
data = undefined;
}
if (!url.startsWith(basePath)){
url=basePath+url;
}
return jQuery.ajax({
type: method,
url: url,
data: data,
success: callback,
dataType: type
});
};
});