# HG changeset patch
# User Dan
# Date 1202690106 18000
# Node ID 35d94240a197d3e699e4a78479a16d79ae88a615
# Parent 7468a663315fcc65ecb7999d647744d5261658e3
Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
diff -r 7468a663315f -r 35d94240a197 includes/clientside/sbedit.js
--- a/includes/clientside/sbedit.js Fri Feb 08 23:20:20 2008 -0500
+++ b/includes/clientside/sbedit.js Sun Feb 10 19:35:06 2008 -0500
@@ -4,7 +4,7 @@
disenable_currentBlock = document.getElementById('disabled_'+id);
ajaxGet(makeUrlNS('Special', 'EditSidebar', 'action=disenable&ajax=true&noheaders&id='+id), function()
{
- if(ajax.readyState == 4)
+ if ( ajax.readyState == 4 && ajax.status == 200 )
{
if(ajax.responseText == 'GOOD')
{
@@ -31,7 +31,7 @@
delete_currentBlock = { 0 : id, 1 : oElm };
ajaxGet(makeUrlNS('Special', 'EditSidebar', 'action=delete&ajax=true&noheaders&id='+id), function()
{
- if(ajax.readyState == 4)
+ if ( ajax.readyState == 4 && ajax.status == 200 )
{
if(ajax.responseText == 'GOOD')
{
@@ -53,7 +53,7 @@
blockEdit_current = { 0 : id, 1 : oElm };
ajaxGet(makeUrlNS('Special', 'EditSidebar', 'action=getsource&noheaders&id='+id), function()
{
- if(ajax.readyState == 4)
+ if ( ajax.readyState == 4 && ajax.status == 200 )
{
id = blockEdit_current[0];
oElm = blockEdit_current[1];
@@ -100,7 +100,7 @@
blockSave_current = { 0 : id, 1 : oElm };
ajaxPost(makeUrlNS('Special', 'EditSidebar', 'noheaders&action=save&id='+id), 'content='+taContent, function()
{
- if(ajax.readyState == 4)
+ if ( ajax.readyState == 4 && ajax.status == 200 )
{
id = blockSave_current[0];
oElm = blockSave_current[1];
@@ -172,7 +172,7 @@
newname = ajaxEscape(newname);
ajaxPost(makeUrlNS('Special', 'EditSidebar', 'ajax&noheaders&action=rename&id='+id), 'newname=' +newname, function()
{
- if ( ajax.readyState == 4 )
+ if ( ajax.readyState == 4 && ajax.status == 200 )
{
parent.removeChild(img);
if ( ajax.responseText != 'GOOD' )
diff -r 7468a663315f -r 35d94240a197 includes/clientside/static/acl.js
--- a/includes/clientside/static/acl.js Fri Feb 08 23:20:20 2008 -0500
+++ b/includes/clientside/static/acl.js Sun Feb 10 19:35:06 2008 -0500
@@ -25,7 +25,7 @@
params = toJSONString(params);
params = ajaxEscape(params);
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() {
- if(ajax.readyState == 4)
+ if ( ajax.readyState == 4 && ajax.status == 200 )
{
var response = String(ajax.responseText + '');
if ( response.substr(0, 1) != '{' )
@@ -66,7 +66,7 @@
params = toJSONString(params);
params = ajaxEscape(params);
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() {
- if(ajax.readyState == 4)
+ if ( ajax.readyState == 4 && ajax.status == 200 )
{
document.getElementById(aclManagerID+'_main').innerHTML = '';
document.getElementById(aclManagerID + '_back').style.display = 'none';
@@ -316,7 +316,7 @@
params = toJSONString(params);
params = ajaxEscape(params);
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() {
- if(ajax.readyState == 4)
+ if ( ajax.readyState == 4 && ajax.status == 200 )
{
var response = String(ajax.responseText + '');
if ( response.substr(0, 1) != '{' )
@@ -459,7 +459,7 @@
params = toJSONString(params);
params = ajaxEscape(params);
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() {
- if(ajax.readyState == 4)
+ if ( ajax.readyState == 4 && ajax.status == 200 )
{
document.getElementById(aclManagerID+'_main').innerHTML = '';
document.getElementById(aclManagerID + '_back').style.display = 'none';
diff -r 7468a663315f -r 35d94240a197 includes/clientside/static/ajax.js
--- a/includes/clientside/static/ajax.js Fri Feb 08 23:20:20 2008 -0500
+++ b/includes/clientside/static/ajax.js Sun Feb 10 19:35:06 2008 -0500
@@ -185,7 +185,7 @@
enableUnload();
setAjaxLoading();
ajaxGet(stdAjaxPrefix+'&_mode=getpage&noheaders', function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
selectButtonMajor('article');
@@ -212,7 +212,7 @@
document.getElementById('protbtn_2').style.textDecoration = 'none';
document.getElementById('protbtn_'+l).style.textDecoration = 'underline';
ajaxPost(stdAjaxPrefix+'&_mode=protect', 'reason='+ajaxEscape(r)+'&level='+l, function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
if(ajax.responseText != 'good')
alert(ajax.responseText);
@@ -229,7 +229,7 @@
if(!r || r=='') return;
setAjaxLoading();
ajaxPost(stdAjaxPrefix+'&_mode=rename', 'newtitle='+ajaxEscape(r), function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
alert(ajax.responseText);
}
@@ -243,7 +243,7 @@
return true;
setAjaxLoading();
ajaxPost(ENANO_SPECIAL_CREATEPAGE, ENANO_CREATEPAGE_PARAMS, function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
window.location.reload();
}
@@ -267,7 +267,7 @@
}
setAjaxLoading();
ajaxPost(stdAjaxPrefix+'&_mode=deletepage', 'reason=' + ajaxEscape(reason), function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
alert(ajax.responseText);
window.location.reload();
@@ -284,7 +284,7 @@
if(!c) return;
setAjaxLoading();
ajaxGet(stdAjaxPrefix+'&_mode=delvote', function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
alert(ajax.responseText);
}
@@ -300,7 +300,7 @@
if(!c) return;
setAjaxLoading();
ajaxGet(stdAjaxPrefix+'&_mode=resetdelvotes', function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
alert(ajax.responseText);
item = document.getElementById('mdgDeleteVoteNoticeBox');
@@ -323,7 +323,7 @@
document.getElementById('wikibtn_2').style.textDecoration = 'none';
document.getElementById('wikibtn_'+val).style.textDecoration = 'underline';
ajaxGet(stdAjaxPrefix+'&_mode=setwikimode&mode='+val, function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
if(ajax.responseText!='GOOD')
{
@@ -344,7 +344,7 @@
return true;
setAjaxLoading();
ajaxGet(stdAjaxPrefix+'&_mode=catedit', function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
edit_open = false;
eval(ajax.responseText);
@@ -372,7 +372,7 @@
setAjaxLoading();
query = query.substring(1, query.length);
ajaxPost(stdAjaxPrefix+'&_mode=catsave', query, function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
edit_open = false;
if(ajax.responseText != 'GOOD') alert(ajax.responseText);
@@ -390,7 +390,7 @@
return true;
setAjaxLoading();
ajaxGet(stdAjaxPrefix+'&_mode=histlist', function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
edit_open = false;
selectButtonMajor('article');
@@ -408,7 +408,7 @@
if(!tit) tit=title;
setAjaxLoading();
ajaxGet(append_sid(scriptPath+'/ajax.php?title='+tit+'&_mode=getpage&oldid='+oldid), function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
edit_open = false;
document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
@@ -422,7 +422,7 @@
return true;
setAjaxLoading();
ajaxGet(stdAjaxPrefix+'&_mode=rollback&id='+id, function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
alert(ajax.responseText);
}
@@ -440,7 +440,7 @@
if(!c) return;
setAjaxLoading();
ajaxGet(stdAjaxPrefix+'&_mode=flushlogs', function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
alert(ajax.responseText);
window.location.reload();
@@ -524,7 +524,7 @@
setAjaxLoading();
ajaxGet(stdAjaxPrefix+'&_mode=pagediff&diff1='+id1+'&diff2='+id2, function()
{
- if(ajax.readyState==4)
+ if ( ajax.readyState == 4 && ajax.status == 200 )
{
unsetAjaxLoading();
document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
@@ -565,7 +565,7 @@
return null;
}
ajaxGet(stdAjaxPrefix + '&_mode=getstyles&id=' + id, function() {
- if ( ajax.readyState == 4 )
+ if ( ajax.readyState == 4 && ajax.status == 200 )
{
// IE doesn't like substr() on ajax.responseText
var response = String(ajax.responseText + ' ');
@@ -640,7 +640,7 @@
ajaxPost(stdAjaxPrefix + '&_mode=change_theme', 'theme_id=' + ajaxEscape(theme_id) + '&style_id=' + ajaxEscape(style_id), function()
{
- if ( ajax.readyState == 4 )
+ if ( ajax.readyState == 4 && ajax.status == 200 )
{
if ( ajax.responseText == 'GOOD' )
{
@@ -696,7 +696,7 @@
function ajaxGetStyles(id) {
setAjaxLoading();
ajaxGet(stdAjaxPrefix+'&_mode=getstyles&id='+id, function() {
- if(ajax.readyState == 4) {
+ if ( ajax.readyState == 4 && ajax.status == 200 ) {
unsetAjaxLoading();
eval(ajax.responseText);
html = '
And a style...