jQuery Ajax Error 0 on Save and Drag Order

6 posts by 3 authors in: Forums > CMS Builder
Last Post: June 7, 2013   (RSS)

By yodare - June 4, 2013

Applies to CMS Builder v2.15 - v2.53 and Firefox v20 - v21

"error 0" POPUP MESSAGE in CMSB admin  (only on following jQuery/Ajax calls):
- Admin > Section Editor > MySection > Field Editor 'Save' button (error 0 popup... saves field options, but must select 'ok' then hit 'Cancel' to exit Field Editor)
- Admin > Section Editor > MySection "drag / sort field order" (error 0 popup... saves field order, but must select 'ok')
- Admin > MyMultiSection "drag / sort record order" (error 0 popup... saves record order, but must select 'ok')

STRANGE, BUT NO "error 0" POPUP MESSAGES FOR: - Admin > Section Editor  "drag / sort section menu order"

SERVER INFO:
Shared Hosting
Linux System running Apache 2
Server API: CGI/FastCGI
MySQL Versions Tested: MySQL v5.0.51a and MySQL v5.0.91
PHP Versions Tested:  PHP v5.2.17 and PHP v5.3.13

ADDITIONAL TROUBLESHOOTING INFO:
I suspected the error started from either a server config update via host or browser bug/depreciated cross-site support. I tested the root html directory AND the CMSB Admin directory (on multiple web servers) using the "php_exit_bug.php" test script that Dave provided in another post. I only receive a "0" response within the CMSB Admin directory. The root directory and all other sub-directories exit with NO response (correctly). So... This leads me to believe a CMSB directory setting is causing the conflict. Any settings within the default CMSB .htaccess or .ini that would cause this?

By gregThomas - June 5, 2013

Hi, 

Is this a bug that has suddenly started happening on your site, or is this a fresh install?

This bug is usually caused by the server set up. The AJAX call should return an empty string if there are no errors, but on some servers zero is returned instead. 

Would you mind filling out a second level support request for me? You can find the form here:

https://www.interactivetools.com/support/email_support_form.php

Then I can take a closer look at what is causing the issue. 

Cheers

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By yodare - June 5, 2013

The issue started around May 17th to previously installed (and working) CMSB's on multiple servers. I'm having our web host look into this first so I don't waste your time if the issue is on their end (wouldn't be the first time).

HOWEVER, I did discover something interesting... If I remove the php.ini file located within the cmsAdmin directory, I receive a 500 error ONLY when trying to access menu items under the "Admin" tab (General Settings, Section Editors, Code Generator, etc.). All the other content editor menu items/links load correctly and content can be modified/saved as usual. I replaced the php.ini file and the Admin menu items started loaded again. Almost seems like paths are modified if any .ini file exists within the cmsAdmin directory.

Does this connect the dots for anyone?

By Dave - June 6, 2013

Hi yodare,

I've attached the php_exit_bug script.  If you haven't already could you upload it to the root of the website and /cmsAdmin/ as well and then email me the urls to dave@interactivetools.com? 

I'd like to see if there is something specific to your server that I can detect for to make the workaround more targeted.  That said, this is usually caused by broken implementation of a cache or proxy server by the web host.  Basically they don't know how to handle blank responses and so they return "0" instead, and a few of our pages that rely on a blank server response to indicate no errors aren't expecting that.

In any case, here's a generic fix.  search for "isBrokenHttpImplementation" and add the code in red below:

var isBrokenHttpImplementation = (jqXHR.getResponseHeader('Server') == 'Nginx / Varnish' && data == '0')
                              || (jqXHR.getResponseHeader('Content-Length') == '0' && data != '');
if (isBrokenHttpImplementation) { data = ''; } // send no output (as intended)

// v2.54 - Disallow content of "0" for jquery ajax
// Notes: Broken web/cache servers return "0" if no content is sent (eg: <?php exit; ?>)
if (data == '0') { data = ''; }

Let me know if that fixes it for you.  Thanks!

PS:  Who is is the host? 

Dave Edis - Senior Developer
interactivetools.com
Attachments:

php_exit_bug_001.php 1K

By yodare - June 7, 2013

Thanks Dave! This workaround fixes my "error 0" popup issue on empty jQuery/AJAX calls! Made my day!

At this point, the issue seems to only effect cmsAdmin directory.  Upon testing, I only receive a "0" response within the CMSB Admin directory on shared servers with Apache 2 and running PHP as CGI. I sent Dave an email with more troubleshooting info; so maybe he'll discover (and hopefully explain) what's happening. Ultimately, I could have a unique issue. We'll see...