function AjaxData(func, _option) {
/// <summary>
///AjaxData
///【創建時間:2019-07-24 11:42:41】
/// </summary>
/// <param name="func">請求url</param>
/// <param name="_option">請求_option ={}</param>
/// <returns>【返回值】</returns>
_option = typeof (_option) == undefined ? {} : _option;
var _url = WebsiteUrl + func;
_url = WebsiteUrl == "/" ? func : _url
$.ajax({
url: _url, //請求的url地址
dataType: _option.dataType || "json", //返回格式爲json
async: _option.async || true,//請求是否異步,默認爲異步,這也是ajax重要特性
data: _option.data || null, //參數值
type: _option.type || "GET", //請求方式
beforeSend: function (res) {
//請求前的處理
if (typeof (_option.beforeSend) == "function") {
_option.beforeSend(res)
}
},
success: function (res) {
//請求成功時處理
if (typeof (_option.success) == "function") {
_option.success(res)
}
},
complete: function (res) {
//請求完成的處理
if (typeof (_option.complete) == "function") {
_option.complete(res)
}
},
error: function (err) {
//請求出錯處理
if (typeof (_option.error) == "function") {
_option.error(err)
}
}
});
}