jQuery Ajax不显示成功警报 [英] JQuery Ajax Not Showing Success Alert
本文介绍了jQuery Ajax不显示成功警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使JQuery Ajax正常工作,但没有收到成功警报.
I am trying to get JQuery Ajax to work but not getting a success alert.
这是代码:
<script type="text/javascript">
$(document).ready(function(
$('button').click(function() {
$.ajax({
url: 'testing123.php',
success: function(){
alert('this worked');
}
});
return false;
});
));
</script>
<button>Click Here</button>
...然后是testing123.php文件:
...then the testing123.php file:
<?php
echo 'Hello there';
?>
我确实也添加了JQuery库.
I DO have JQuery library added too.
当我单击按钮时,我应该收到一条警告,说这行得通",对吗?
When I click the button I should be getting an alert saying "this worked" right?
我不明白为什么它没有发生...
I don't understand why it's not happening...
有什么想法吗?
推荐答案
不正确地使用了括号.更正的代码:
Incorrect use of parantheses. Corrected code:
$(document).ready(function() {
$('button').click(function() {
$.ajax({
url: 'testing123.php',
success: function(){
alert('this worked');
}
});
return false;
});
});
这篇关于jQuery Ajax不显示成功警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文