如果您恰好使用了ff浏览器(偶用ff3.0),server端使用了nginx作代理,而某个ajax又恰好传了一个为null的数据,您就会看到这个错误
firefox下点run code运行下面代码,firebug 看控制台
<html>
<input type="button" value="send null ajax" onclick="send();" />
</html>
<script>
function send()
{
var rq = new XMLHttpRequest();
rq.open("POST", "http://bluehua.org/index.php", true);
rq.send( null );
}
</script>
两种解决方法:
client side : rq.send( data ) -> rq.send( data || ” );
server side :
When using POST method to request via Nginx 0.6.33 without any post body data, you may get this error: 411 Length Required.
Download nginx-0.6.33-length_required patch Save the attachment and run this command in the root path of nginx 0.6.33 source code: patch ./src/http/ngx_http_request.c<nginx-0_6_33-length_required.patch Then "make && make install && sudo /sbin/service nginx restart" and enjoy your AJAX function.