我有多個表格,並且每個表格都有一個按鈕,單擊該按鈕時應使與該按鈕標題相關的特定文件夾的所有圖像都出現在旋轉木馬中。php顯示旋轉木馬中某個文件夾的所有圖像
我能夠通過AJAX傳遞包含文件夾名稱的變量,但從那裏我不知道如何將該值傳回到PHP文件並加載/重新加載該div來顯示圖像。 有什麼建議嗎?
PHP文件:
echo "<button method='post' class='btn view' name='view' data-toggle='modal' href='.myModal' value='$a' >View Images</button>";
/* some code*/
<div class='myModal'>
/*some code to display images of a folder in a carousel, the folder name of which is in data of ajax call*/
</div>
AJAX調用:
$(".view").click(function() {
$.ajax({
url:"view.php",
data:{view:$(this).val()},
type:"POST",
success:function(data){
console.log(data);
if (data!=""){
alert(data);
}
},
error:function(data){
alert("Network ERROR");
}
})
return false;
});