|
Revision 85
(checked in by fumanchu, 6 years ago)
|
ajax: Fix for IE status code 1223.
|
| Line | |
|---|
| 1 |
function http() { |
|---|
| 2 |
var h; |
|---|
| 3 |
if (typeof(XMLHttpRequest) != "undefined") { |
|---|
| 4 |
h = new XMLHttpRequest(); |
|---|
| 5 |
} else { |
|---|
| 6 |
try { h = new ActiveXObject("Msxml2.XMLHTTP"); } |
|---|
| 7 |
catch (e) { |
|---|
| 8 |
try { h = new ActiveXObject("Microsoft.XMLHTTP"); } |
|---|
| 9 |
catch (E) { alert("Your browser is not supported."); } |
|---|
| 10 |
} |
|---|
| 11 |
} |
|---|
| 12 |
return h |
|---|
| 13 |
} |
|---|
| 14 |
|
|---|
| 15 |
function http_action(callback) { |
|---|
| 16 |
var h = http(); |
|---|
| 17 |
h.onreadystatechange = function() { |
|---|
| 18 |
if (h.readyState == 4) { |
|---|
| 19 |
if (h.status != 200 && h.status != 204 |
|---|
| 20 |
|
|---|
| 21 |
&& h.status != 1223) { |
|---|
| 22 |
alert("Error. Status = " + h.status + "\n" + h.responseText); |
|---|
| 23 |
} else { |
|---|
| 24 |
var result = ""; |
|---|
| 25 |
var ct = h.getResponseHeader("Content-Type"); |
|---|
| 26 |
if (ct.split(";")[0] == "text/xml") { |
|---|
| 27 |
try { |
|---|
| 28 |
result = h.responseXML; |
|---|
| 29 |
if (xmldoc == null) throw "No XML in response"; |
|---|
| 30 |
} catch (e) { |
|---|
| 31 |
result = h.responseText; |
|---|
| 32 |
alert(h.responseText); |
|---|
| 33 |
return; |
|---|
| 34 |
} |
|---|
| 35 |
} else { |
|---|
| 36 |
result = h.responseText; |
|---|
| 37 |
} |
|---|
| 38 |
if (callback != undefined) callback(result); |
|---|
| 39 |
} |
|---|
| 40 |
} |
|---|
| 41 |
} |
|---|
| 42 |
return h; |
|---|
| 43 |
} |
|---|