背景:
我有一个带有内部 PHP 处理脚本的 HTML 表单,该脚本采用复选框类别并将它们转换为传递到 glob() 函数的图像目录位置字符串。
情况:
我有一组来自 glob 函数的图像 src 路径
例子
<?php
$images //ARRAY OF IMG SRC PATHS
?>
我想附加点击和键盘事件以循环遍历 $images 数组
例子
$(document).ready(function(){
$('#img_viewer').click(function(){
//LOOP THROUGH $images array on click one at a time
});
});
最佳答案
你为什么不试试这个
$(#img_viewer).click(function(){
$.ajax({
method:'post',
url: 'the url for the php file',
data:{}, // you can pass any data that can used to your php file
success:function(respose){
// do something
}
});
})
关于php - 使用 Jquery 事件处理程序循环遍历 PHP 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48485016/