-1
我已經寫了一個函數的ajax調用來點擊圖像時觸發。在php頁面中,圖像使用php gd旋轉。不知何故,阿賈克斯沒有被觸發。我無法弄清楚我在犯什麼錯誤!這個Ajax調用有什麼問題?
JQuery的:
$(document).ready(function() {
$("#rotate-head-1").click(function(){
alert("Function running");
var filename = document.getElementById('image-1').getAttribute('src');
$.ajax({
url:"test.php",
type:"GET",
async:true,
data:{procedure:"rotate",file_name:filename},
cache:false
success: function(data) {
alert("Success");
}
error: function() {
alert("Failure");
}
});
});
});
HTML:
<img id="rotate-head-1" src="rotate_icon.jpg" width="20" height="20" border="0" alt="Rotate Image" title="Rotate Image">
<img id="image-1" src="../../member_media/media/test.jpeg" width="200" border="0">
任何幫助或建議,將不勝感激。
控制檯中的任何錯誤? – laaposto
那麼整個點擊處理程序沒有被觸發?或者它只是ajax呼叫? – gpgekko
當我刪除$ .ajax({..中的所有內容,然後「函數運行」警報正在工作,但是當我把它放在這裏時,沒有任何工作(包括那個警報) – programmer