默认情况下Ajax以 Content-Type: text/plain 提交数据,此时服务器将忽略POST实体部分的数据,所以服务端程序无法获取POST数据。
因此要在send()方法前设置Ajax的Content-Type属性,
将属性Content-Type设置为application/x-www-form-urlencoded
方法如下:ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");