Home >Backend Development >PHP Tutorial >The value obtained by js-JS is posted to the PHP code.
jsphphtml
<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>
Run the above js after clicking the submit button, and then post the imageStr array to 1.php without returning
Quoting jquery’s ajax
<code> $("#id").click(function(){ var imageStr;//你要发送的参数 $.ajax({ type:"POST", url:"1.PHP", data:{ IMGSTR:imageStr }, dataType:'json', success:function(json){ //回调函数 } }); }) </code>
. Use ajax to transfer values, such as $.post (page, JSON format data, callback function);
This must be using ajax. There are many examples on the Internet and it will be fine