sami_until.js
2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//ajax封装
(function ($) {
$.extend({
ajaxSend: function (urlSuffix,params) {
console.log(params);
var prefixUrl = "http://192.168.1.21/";//仅为测试使用
// $("head").append('<script src="'+prefixUrl + urlSuffix+'&"></script>');
return $.ajax({
url: prefixUrl + urlSuffix,
type: 'post',
dataType: 'jsonp',
async: true,
//contentType: 'application/json;charset=UTF-8',
data:params,
beforeSend: function () {
}
}).done(function (data) {
console.log(data);
}).fail(function (data) {
}).always(function () {
});
},
getCookie: function (name) {
var cookieName = encodeURIComponent(name) + "=";
var cookieStart = document.cookie.indexOf(cookieName);
var cookieValue = null;
if (cookieStart > -1) {
var cookieEnd = document.cookie.indexOf(";", cookieStart);
if (cookieEnd == -1) {
cookieEnd = document.cookie.length;
}
cookieValue = encodeURIComponent(document.cookie.substring(cookieStart + cookieName.length, cookieEnd));
}
return decodeURIComponent(decodeURIComponent(cookieValue));
},
setCookie: function (name, value, days, path, domain, secure) {
var cookieText = encodeURIComponent(name) + "=" + encodeURIComponent(value);
if (days>0) {
var expires = new Date();
expires.setTime(expires.getTime() + days * 3600000 * 24);
//expires.setTime(expires.getTime() + days * 120000);
var _expires = (typeof days) == "string" ? "" : ";expires=" + expires.toUTCString();
cookieText = encodeURIComponent(name) + "=" + encodeURIComponent(value)+ _expires + path;
}
if (path) {
cookieText += "; path=" + path;
}
if (domain) {
cookieText += "; domain=" + domain;
}
if (secure) {
cookieText += "; secure"
}
document.cookie = cookieText;
},
unsetCookie: function (name,days, path, domain, secure) {
this.setCookie(name, "", days, path, domain, secure);
}
})
})(jQuery);