<code><script> var images = document.getElementsByClassName("c1"); var imageStr = ""; for(var i=0;i<images.length;i++){ imageStr+=images[i].src+'_'; } alert(imageStr); </script> </code>
如何設定一個按鈕,點選後post imageStr裡面的陣列到PHP
<code>$imageStr = "http://127.0.0.1/down/123.gif__http://127.0.0.1/down/8095680852_893f685cbd_q.jpg__http://127.0.0.1/down/8018953043_c6ef9e3b29_q.jpg__"; </code>
提問前請先搜尋相關答案:
https://segmentfault.com/sear...
<code><script> var images = document.getElementsByClassName("c1"); var imageStr = ""; for(var i=0;i<images.length;i++){ imageStr+=images[i].src+'_'; } alert(imageStr); </script> </code>
如何設定一個按鈕,點選後post imageStr裡面的陣列到PHP
<code>$imageStr = "http://127.0.0.1/down/123.gif__http://127.0.0.1/down/8095680852_893f685cbd_q.jpg__http://127.0.0.1/down/8018953043_c6ef9e3b29_q.jpg__"; </code>
提問前請先搜尋相關答案:
https://segmentfault.com/sear...
範例
<code>$( "#lock_submit").click(function (){ var lock_form = $("#lock_form").serialize(); // 参数带在form里面用form表单 var onePush = "xxx/xxx/xxx.php" ; var imageStr ="http://127.0.0.1/down/123.gif__http://127.0.0.1/down/8095680852_893f685cbd_q.jpg__http://127.0.0.1/down/8018953043_c6ef9e3b29_q.jpg__"; $.ajax({ url: onePush , type:"POST", data:{image:imageStr},//data:lock_form form提交 dataType : "json", success :function(data){ if(data.status== 1){ alert('操作成功') // 刷选页面 location. reload(); }else{ alert('操作失败') } } }) }) </code>
表單提交就可以了
$.post(url,{imageStr:$imageStr},function(res){
<code>//do somethings </code>
})