一开始我是准备使用post进行ajax进行异步操作
xhr=new XMLHttpRequest();
xhr.open('post','m.php',true);
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.send('date='+cdate); //cdate是获取的日期值
但是服务器的中$_POST['date']却显示为空,请问这是为什么呢?
最后是换成了GET方法成功获取数据
xhr.open('get','m.php?date='+cdate,true); //cdate是获取的日期值
xhr.send();
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
是这个原因吗?
还是用JQ吧。几乎网站都会引用,不用不是浪费了。 现在的技术是不要重复造轮子,浪费资源!
是不是需要写成
send('date='+encodeURIComponent(cdate))这样?