我使用的是select2插件
我能够在jquery中获得选定的标签数组,但是我如何将数组附加到DOM和在php中获得表单提交或任何其他方法的值?
在我的表单中有多个文件上传,所以我不想要ajax。这是我应用select2
的标签。
<input type="hidden" id="tags" value="tag" style="width: 400px;">
下面是我正在使用的小提琴:http://jsfiddle.net/X6V2s/66/
我有一个数组的值在jquery中,但希望它在php。
我可以追加数组到DOM(如果是,然后?如何)
我怎样才能做到这一点?请帮帮我。
尝试在提交表单之前设置选定标签的cookie。那么你可以访问php
注意:不要忘记在表单提交后删除cookie。
JS: using jQuery Cookie要进一步了解jQuery Cookie,请阅读此处的
$.cookie("test", 1, {
expires : 10, //expires in 10 days
path : '/', //The value of the path attribute of the cookie
//(default: path of page that created the cookie).
domain : 'yourdomain.com', //The value of the domain attribute of the cookie
//(default: domain of page that created the cookie).
secure : true //If set to true the secure attribute of the cookie
//will be set and the cookie transmission will
//require a secure protocol (defaults to false).
});
PHP读取服务器端cookie
echo $_COOKIE('test');