-
Notifications
You must be signed in to change notification settings - Fork 0
/
(20220317)_ty_ajax_xml.js
51 lines (50 loc) · 1.38 KB
/
(20220317)_ty_ajax_xml.js
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
//xmlhttp
//create xmlhttp object
function createRequest() {
try {
var objXML;
objXML = new XMLHttpRequest();
//return objXML;
} catch (trymicrosoft) {
try {
objXML = new ActiveXObject("Msxml2.XMLHTTP");
//return objXML;
} catch (othermicrosoft) {
try {
objXML = new ActiveXObject("Microsoft.XMLHTTP");
//return objXML;
} catch (failed) {
objXML = false;
//return objXML;
}
}
}
if (!objXML){
alert("Error initializing XMLHttpRequest!");
}
return objXML;
}
//--------------------------------
//GET-text/plain
function ajaxsendtextbyget(objx,strurl,strfunction){
objx.open("GET", strurl, true);
objx.setRequestHeader("Content-Type", "text/plain");
objx.onreadystatechange=eval(strfunction);
objx.send(null);
}
//POST-text/plain
function ajaxsendtextbypost(objx,strurl,strlist,strfunction){
objx.open("POST", strurl, true);
objx.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
objx.onreadystatechange=eval(strfunction);
objx.send(strlist);
}
//POST text/xml
function ajaxsendxmlbypost(objx,strurl,strxml,strfunction){
objx.open("POST", strurl, true);
objx.setRequestHeader("Content-Type", "text/xml");
objx.onreadystatechange=eval(strfunction);
objx.send(strxml);
}
//-------------------------
//-------------------------