jquery.ajax() POST receives empty response with IE10 on Nginx/PHP-FPM but works on Apache

apache, character-encoding, internet-explorer-10, jquery, nginx

Solution

Please also check the Content-Type Header, since Apache and Nginx are sending different values:

Content-Type: text/html; charset=UTF-8

vs.

Content-Type: text/html; charset=utf8

Update your Nginx config, add this line:

charset UTF-8;

Problem

I use a very simple `jquery.ajax()` call to fetch some HTML snippet from a server: ``` // Init add lines button $('body').on('click', '.add-lines', function(e) { $.ajax({ type : 'POST', url : $(this).attr('href')+'?ajax=1&addlines=1', data : $('#quickorder').serialize(), success : function(data,x,y) { $('#directorderform').replaceWith(data); }, dataType : 'html' }); e.preventDefault(); }); ``` On the PHP side i basically echo out a HTML string. The jQuery version is 1.8.3. The problem is in IE10: While it works fine there on Server A which runs on Apache it fails on Server B which runs on Nginx + PHP-FPM: If i debug the `success` handler on Server B I get a `undefined` for `data`. In the Network tab of the IE developer tools I can see the full response and all headers. It may affect other IE versions, but i could only test IE10 so far. Here are the two response headers: Server A, Apache (works): ``` HTTP/1.1 200 OK Date: Thu, 25 Apr 2013 13:28:08 GMT Server: Apache Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Vary: Accept-Encoding,User-Agent Content-Encoding: gzip Content-Length: 1268 Keep-Alive: timeout=2, max=100 Connection: Keep-Alive Content-Type: text/html; charset=UTF-8 ``` Server B, Nginx + PHP-FPM (fails): ``` HTTP/1.1 200 OK Server: nginx/1.1.19 Date: Thu, 25 Apr 2013 13:41:43 GMT Content-Type: text/html; charset=utf8 Transfer-Encoding: chunked Connection: keep-alive Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-Encoding: gzip ``` The body part looks the same in both cases. Any idea what could cause this issue?

Original source