mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Template/Update (Part 47)
* split global.js into its components, so it can be reasonably processed by setup * make reputation requirements configurable * move Markup and Locale back into global.js (removed associated build scripts) * extend Icon to display iconId in lightbox popup
This commit is contained in:
51
setup/tools/filegen/templates/global.js/ajax.js
Normal file
51
setup/tools/filegen/templates/global.js/ajax.js
Normal file
@@ -0,0 +1,51 @@
|
||||
function Ajax(url, opt)
|
||||
{
|
||||
if (!url)
|
||||
return;
|
||||
|
||||
var _;
|
||||
|
||||
try { _ = new XMLHttpRequest() } catch (e)
|
||||
{
|
||||
try { _ = new ActiveXObject("Msxml2.XMLHTTP") } catch (e)
|
||||
{
|
||||
try { _ = new ActiveXObject("Microsoft.XMLHTTP") } catch (e)
|
||||
{
|
||||
if (window.createRequest)
|
||||
_ = window.createRequest();
|
||||
else
|
||||
{
|
||||
alert(LANG.message_ajaxnotsupported);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.request = _;
|
||||
|
||||
$WH.cO(this, opt);
|
||||
this.method = this.method || (this.params && 'POST') || 'GET';
|
||||
|
||||
_.open(this.method, url, this.async == null ? true : this.async);
|
||||
_.onreadystatechange = Ajax.onReadyStateChange.bind(this);
|
||||
|
||||
if (this.method.toUpperCase() == 'POST')
|
||||
_.setRequestHeader('Content-Type', (this.contentType || 'application/x-www-form-urlencoded') + '; charset=' + (this.encoding || 'UTF-8'));
|
||||
|
||||
_.send(this.params);
|
||||
}
|
||||
|
||||
Ajax.onReadyStateChange = function()
|
||||
{
|
||||
if (this.request.readyState == 4)
|
||||
{
|
||||
if (this.request.status == 0 || (this.request.status >= 200 && this.request.status < 300))
|
||||
this.onSuccess != null && this.onSuccess(this.request, this);
|
||||
else
|
||||
this.onFailure != null && this.onFailure(this.request, this);
|
||||
|
||||
if (this.onComplete != null)
|
||||
this.onComplete(this.request, this);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user