diff options
-rw-r--r-- | lib/ajaxlib.lua | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/ajaxlib.lua b/lib/ajaxlib.lua index 398d3b1..9a37daf 100644 --- a/lib/ajaxlib.lua +++ b/lib/ajaxlib.lua @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: ajaxlib.lua,v 1.2 2008-01-15 18:20:23 pixel Exp $ */ +/* $Id: ajaxlib.lua,v 1.3 2008-01-21 04:03:43 pixel Exp $ */ ]]-- @@ -57,6 +57,7 @@ end ajaxlib_javascript = [[ var loading = 0; +var isIE = false; function ajax_loading(v) { @@ -87,17 +88,40 @@ function ajax_hub(ajax_request, callback) ajax_loading(loading != 0); } +function new_XMLHttpRequest() +{ + var r; + + if (window.XMLHttpRequest) { + r = new XMLHttpRequest(); + // branch for IE/Windows ActiveX version + } else if (window.ActiveXObject) { + r = new ActiveXObject("Microsoft.XMLHTTP"); + isIE = true; + } + + return r; +} + function ajax_create(url, callback) { var ajax_request; + ajax_request = new_XMLHttpRequest(); + + if (!ajax_request) + return; + loading++; ajax_loading(true); - ajax_request = new XMLHttpRequest(); ajax_request.onreadystatechange = function() { ajax_hub(ajax_request, callback) }; ajax_request.open("GET", url, true); - ajax_request.send(null); + if (isIE) { + ajax_request.send(); + } else { + ajax_request.send(null); + } } function ajax_do_get_data(res) |