500 error from call to XMLHttpRequest() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: 500 error from call to XMLHttpRequest() (/showthread.php?tid=71706) |
500 error from call to XMLHttpRequest() - richb201 - 09-14-2018 I am getting a 500 error on the Linux version of my code. The version on my WAMP under windows doesn't have this issue. The LAMP version is a Bitnami instance running on AWS. I took a look in the error.log and I see: malformed header from script 'index.php': Bad header: {"0":["{choose}","IOS","Mac"," and AH01070: Error parsing script headers I see that AH01070 is an Apache bug. I am running on AWS LightSail. This is where I set my headers in my CI code: $this->output ->set_content_type('application/json') ->set_header("Access-Control-Allow-Origin", "*") ->set_output(json_encode($table)); Any ideas? Do I need to move back to Windows? RE: 500 error from call to XMLHttpRequest() - skunkbad - 09-15-2018 (09-14-2018, 08:11 PM)Hrichb201 Wrote: ... You should start developing on an environment that matches the production environment as much as possible. RE: 500 error from call to XMLHttpRequest() - richb201 - 09-15-2018 valid point. My problem might be a need to set a Content-Length in the header. I added: ->set_header("Content-Length: 1000") And it still gives me a 500 error, but at least the error in the error log went away. How do I get the actual length of a json encoded structure (instead of 1000)? RE: 500 error from call to XMLHttpRequest() - Piotr - 09-15-2018 (09-15-2018, 01:58 AM)richb201 Wrote: valid point. My problem might be a need to set a Content-Length in the header. strlen(json_encode($table)); ?? RE: 500 error from call to XMLHttpRequest() - richb201 - 09-16-2018 Could the issue be that the windows server (that works) is https while the Linux is http? Other than that, the php.ini is clearly different, too. |