This question straddles both programming and server issues, not sure it is 100% for serverfault. Here it goes:
I just migrated my Codeigniter (PHP 5.1.2) web app to a new server. In the old server, everything worked normally.
In the new server, all jQuery Ajax is broken, and I’ve noticed errors affect exclusively Ajax that uses json data.
The errors on Firebug show as
data is null //data is a json string returned by the server
if (data.success == 1) {
and on Chrome console the same error shows as
Uncaught TypeError: Cannot read property 'success' of null
A few details about the new server:
- Red Hat Enterprise Linux
- Plesk 9
- PHP is enabled via Plesk interface – the setting is ‘Run PHP as Fast CGI, safe_mode off’
- It has a firewall that is not causing any obvious problems
-
.htaccess is currently very lean
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?/$1 [L] Header set X-UA-Compatible "IE=EmulateIE8" <IfModule mod_deflate.c> <IfModule mod_setenvif.c> BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html </IfModule> <IfModule mod_headers.c> Header append Vary User-Agent env=!dont-vary </IfModule> AddOutputFilterByType DEFLATE text/css application/x-javascript text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon </IfModule> <IfModule mod_headers.c> <FilesMatch "\.(jpg|jpeg|ico|gif|png|flv|pdf)$"> Header set Cache-Control "max-age=2700" </FilesMatch> </IfModule>
In addition:
- one part of the webapp uses jQuery FullCalendar – before the migration it worked perfectly – now I get a blank page (no errors on console – but it uses several JSON strings to populate calendar events
- login using Facebook and Google credentials is broken leading to blank pages (not sure of JSON strings here).
I’ve tried changing json to jsonp as suggested elswhere on SO, but this didn’t solve the problem. Is any other change to the code required?
Thanks for reading — any suggestions how to begin troubleshooting this?
This was resolved by upgrading my PHP version from 5.1.2 (the default install for Plesk 9.5) to PHP 5.3.x.
http://www.atomicorp.com/wiki/index.php/PHP
The problem was probably due to my using
json_encode, which is a PHP > 5.2 function.Hope this helps anyone out there with similar issues.