[英]What's wrong with this Ajax call?
我已经从函数编写了一个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">
任何帮助或建议,将不胜感激。
我看到的是在使用cache
和success
选项后缺少逗号。 这些错误应该出现在控制台中,您可以使用它来动态调试此类问题。
$(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 //<-- you miss a comma here?
success: function(data) {
alert("Success");
} // <-- and miss a comma here
error: function() {
alert("Failure");
}
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.