PageSourceSearch

https://www.huaxingas.com/template/zll/static/js/ajax.js

js huaxingas.com collected 2026-10-05 21:38:23 UTC 1,766 bytes, 83 lines download raw bytes

1var ajax = function(options) {
2	/**
3	 * 传入方式默认为对象
4	 * */
5	options = options || {};
6	/**
7	 * 默认为GET请求
8	 * */
9	options.type = (options.type || "GET").toUpperCase();
10	/**
11	 * 返回值类型默认为json
12	 * */
13	options.dataType = options.dataType || 'json';
14	/**
15	 * 默认为异步请求
16	 * */
17	options.async = options.async || true;
18	/**
19	 * 对需要传入的参数的处理
20	 * */
21	var params = getParams(options.data);
22	var xhr;
23	/**
24	 * 创建一个 ajax请求
25	 * W3C标准和IE标准
26	 */
27	if (window.XMLHttpRequest) {
28		/**
29		 * W3C标准
30		 * */
31		xhr = new XMLHttpRequest();
32	} else {
33		/**
34		 * IE标准
35		 * @type {ActiveXObject}
36		 */
37		xhr = new ActiveXObject('Microsoft.XMLHTTP')
38	}
39	xhr.onreadystatechange = function() {
40		if (xhr.readyState == 4) {
41			var status = xhr.status;
42			if (status >= 200 && status < 300) {
43				options.success && options.success(xhr.responseText, xhr.responseXML);
44			} else {
45				options.fail && options.fail(status);
46			}
47		}
48	};
49	if (options.type == 'GET') {
50		xhr.open("GET", options.url + '?' + params, options.async);
51		
52			xhr.send(null)
53		
54			console.log('请求失败')
55		
56	} else if (options.type == 'POST') {
57		/**
58		 *打开请求
59		 * */
60		xhr.open('POST', options.url, options.async);
61		/**
62		 * POST请求设置请求头
63		 * */
64		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
65		/**
66		 * 发送请求参数
67		 */
68		xhr.send(params);
69	}
70}
71/**
72 * 对象参数的处理
73 * @param data
74 * @returns {string}
75 */
76var getParams =function(data) {
77	var arr = [];
78	for (var param in data) {
79		arr.push(encodeURIComponent(param) + '=' + encodeURIComponent(data[param]));
80	}
81	// arr.push(('randomNumber=' + Math.random()).replace('.'));
82	return arr.join('&');
83}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.