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 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...

By Dave - June 7, 2013

Hi Guys, 

I'll just post a follow up here for anyone else who has the same issue.

This is a historical issue with IPowerWeb's caching server implementation.   If there's no content they send "0".  

IPowerWeb knows it's an issue, but is worried changing it will cause more issues, so we've added the above patch to the code to workaround it.

The reason why it occurs under /cmsAdmin/ but not the root is because they "zip" output in the root (Content-Encoding: gzip) but we turn that feature off under /cmsAdmin/ as it can cause other problems.   If you zip or compress even nothing you still get a few bytes to identify it as zipped content, and the zero is only sent when there is no content.

Anyways, we work-around issues like this all the time with all kinds of web hosts, so anyone having the problem should just the patch or upgrade to the new version when it's released and you'll be fine.

Hope that helps!  Let me know any questions.  Thanks.

Dave Edis - Senior Developer
interactivetools.com