我有一个ul列表
< ul id =“new_fields”> < li id =“id_1”class =“ui-state-default”> list 1< / li> < li id =“id_7”class =“ui-state-default”> list 2< / li> < li id =“id_4”……
您可以使用javascript获取ID和Ajax调用以将其发布到URL。
lists = document.getElementsByClassName('ui-state-default'); x = [] for (var i=0, im=lists.length; im>i; i++) { x[i] = lists[i].id; } // Here x will be ['id_1','id_7','id_4']
然后使用ajax将其发布到URL。
var url = "your_url_here.php"; var params = "array=" + x.toString(); http.open("POST", url, true); //Send the proper header information along with the request http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { alert(http.responseText); } } http.send(params);