[英]How to pass multselected js variable value to php variable
.bind('dpClosed',function(e, selectedDates) {
console.log('You closed the date picker and the ' // wrap
+ 'currently selected dates are:');
console.log(selectedDates);
var ll=document.getElementById('ll');
ll.value=selectedDates;
}
);
我想将selectedDates
变量传递给php变量
从前端将变量值传递到服务器端的唯一方法是表单提交或使用Ajax。
因为如果您有一个页面,这两个脚本将在不同的位置运行,则无法为php分配js变量,因为php在服务器上运行,并且它已经在页面加载之前运行了。
您必须为此使用ajax或表单提交:
$.post('the/url/to/post', {selectedDates:selectedDates}, function(response){
console.log(response);
});
现在在php中,您可以通过以下方式获得它:
$_POST['selectedDates']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.