diff options
author | grum <grum@piwigo.org> | 2008-08-03 07:48:39 +0000 |
---|---|---|
committer | grum <grum@piwigo.org> | 2008-08-03 07:48:39 +0000 |
commit | 7ebed797262c7f3371ae1b16ed455f7e9879caf0 (patch) | |
tree | 7abef8d2994ae2efa66f38e3027369c7ac0e3926 /plugins/grum_plugins_classes-2/ajax.js | |
parent | ee0af5d43d607ffb969a10e6a21e9df923651d52 (diff) |
Asked by rvelices on this topic
http://forum.phpwebgallery.net/viewtopic.php?pid=92097#p92097
A plugin to integrate the menu class
see test_menu directory
A plugin to show how to use the menu class
see AMenuManager directory
And common classes needed for the AMenuManager plugin
see grum_plugins_classes-2 directory
See topic http://forum.phpwebgallery.net/viewtopic.php?pid=92637#p92637 for more
informations
git-svn-id: http://piwigo.org/svn/trunk@2466 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'plugins/grum_plugins_classes-2/ajax.js')
-rwxr-xr-x | plugins/grum_plugins_classes-2/ajax.js | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/plugins/grum_plugins_classes-2/ajax.js b/plugins/grum_plugins_classes-2/ajax.js new file mode 100755 index 000000000..1b8008191 --- /dev/null +++ b/plugins/grum_plugins_classes-2/ajax.js @@ -0,0 +1,104 @@ +/* ----------------------------------------------------------------------------- + file: ajax.js + file version: 1.1.0 + date: 2008-05-25 + ------------------------------------------------------------------------------ + author: grum at grum.dnsalias.com + << May the Little SpaceFrog be with you >> + ------------------------------------------------------------------------------ + + this classes provides base functions to add ajax into html page + + + create_httpobject provide a simple function to create an HTML request to a + server ; return an XMLHttpRequest object (or compatible object for IE) + + + tHttpObject is a class providing : + - an XMLHttpRequest object + - + + ------------------------------------------------------------------------------ + HISTORY VERSION + v1.0.1 + [create_httpobject] overrideMimeType unknown by IE 7.0 ; + v1.1.0 + add create_httpobject2 with mimetype parameter + + -------------------------------------------------------------------------- */ + + + function create_httpobject(requesttype, charset, ajaxurl, async) + { + return(create_httpobject2(requesttype, charset, ajaxurl, async, '')); + } + + function create_httpobject2(requesttype, charset, ajaxurl, async, mimetype) + { + if (window.XMLHttpRequest) + { + // IE7 & FF method + http_request = new XMLHttpRequest(); + } + else + { + //Other IE method..... + if (window.ActiveXObject) + { + try + { + http_request = new ActiveXObject("Msxml2.XMLHTTP"); + } + catch (e) + { + try + { + http_request = new ActiveXObject("Microsoft.XMLHTTP"); + } + catch (e) + { + window.alert("Your browser is unable to use XMLHTTPRequest"); + } // try-catch + } // try-catch + } + } // if-else + + if(charset=='') { charset='utf-8'; } + + http_request.onreadystatechange = function() { }; + http_request.open(requesttype.toUpperCase(), ajaxurl, async); + + if(mimetype=='') + { + mimetype='text/html'; + } + + try + { + http_request.overrideMimeType(mimetype+'; charset='+charset); + } + catch(e) + { + } + + if(requesttype.toUpperCase()=='POST') + { + http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + } + + //method to restitute an XML object ; needed for compatibility between FF&IE + http_request.XML = httpobject_responseXML; + + return(http_request); + } + + + function httpobject_responseXML() + { + if (document.implementation && document.implementation.createDocument) + { + //ff method + return(this.responseXML); + } + else + { + //ie method + return(xmlCreateFromString(this.responseText)); + } + }
\ No newline at end of file |