Reputation: 3433
I have a controller in CodeIgniter which have few functions in it. For ajax interaction, in some functions where i had to return json
objects, i did the following :
$this->output->set_content_type("application/json");
The ajax is working fine. But now when i'm trying to echo something from a function and going to that function in browser gives me the following :
Content Encoding Error
The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.
I tried setting content type to "text/html", i don't know. Also i tried removing all those content type set. That also didn't help me echoing out of the controller.
What should i do, to echo something out of a specific controller function just in case for testing purposes?
Upvotes: 0
Views: 991
Reputation:
You seem to have GZIP compression turned on in your config. it might mess with your AJAX transfers and/or caching.
By default you don't need to give a content-type when serving json encoded data. So it's better to leave the whole content-type out to prevent future issues. Besides that it's also handy because there can be occasions where you might have one AJAX call give either a JSON encoded string or just a piece of output.
Good luck!
Upvotes: 1