ajax异步与同步提交注意事项

来源:互联网 发布:js单选按钮选中的值 编辑:程序博客网 时间:2024/04/30 14:14
ajax中,当xmlhttp.open("POST", " ", false)中最后一个参数为false,即同步提交时,通常这句xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")代码不用写,但这个有个前提,前提是xmlhttp.send(null);   当xmlhttp.send()中参数不为空时,则xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")必须写上,否则后台接收到的参数的值为空。


这是鄙人最近的经验总结,欢迎吐槽,共同学习,共同进步。

0 0