Hi,
I'm using the Kohana PHP Framework for an application. Now I'm running into a problem, when jQuery does an AJAX request to a certain file, it does work, but when this file throws an PHP exception, jQuery fails and doesn't show the output of the file.
A little example, this is the piece of Javascript:
$.post($('#' + e.currentTarget.id).attr('action'), $('#' + e.currentTarget.id).serialize(), function ( data )
{
alert ( data );
}/*, 'json' */);
Now this works when the PHP file does this (the alert box pops up):
<?php echo 'Test'; ?>
But when somewhere in the PHP file this happens:
<?php throw new Exception ( 'Test' ); ?>
jQuery fails and doesn't show the outputted HTML error, also there is a difference in PHP headers (generated by PHP?):
With the PHP echo (good):
. Connection:Keep-Alive
. Content-Encoding:gzip
. Content-Length:544
. Content-Type:text/html; charset=UTF-8
. Date:Wed, 22 Jul 2009 14:22:43 GMT
. Keep-Alive:timeout=15, max=100
. Server:Apache/2.0.59 (Unix) PHP/5.2.6 DAV/2
. Vary:Accept-Encoding
. X-Powered-By:PHP/5.2.6
With the PHP exception (fail):
. Connection:close
. Content-Encoding:gzip
. Content-Length:1896
. Content-Type:text/html; charset=UTF-8
. Date:Wed, 22 Jul 2009 14:23:11 GMT
. Server:Apache/2.0.59 (Unix) PHP/5.2.6 DAV/2
. Vary:Accept-Encoding
. X-Powered-By:PHP/5.2.6
Now I don't really see a problem, both ways PHP echoes some HTML. Somebody had this problem before, and how'd you fix this?
Thanks for the help!