我一直在摆弄这个,但完全没有任何进展或运气。如果我取出 .ajax 它工作正常,但使用 .ajax 则不会触发任何事件,甚至不会触发随机测试警报。你能看出我做错了什么吗?我尝试遵循 Jquery 文档。 PHP 可以工作。
<script type="text/javascript">
jQuery(document).ready(function ($) { // wait until the document is ready
$('div#chatroom').click(function(){
$.ajax({
type: 'GET',
url: 'chatget.php',
data: { chatroomid: = '<?php echo $chatroomid; ?>'},
datatype: 'html',
cache: 'false',
success: function(response) {
$('#chatroom').append(response);
alert('Load was performed.');
},
error: function(){
alert('Fuuuuuuuuuuuuuu');
}
}); // End Ajax
alert('Fail');
}); // End onclick
});
</script>
最佳答案
只是看看它..数据对象中有一个额外的=
data: { chatroomid: = '<?php echo $chatroomid; ?>'},
------^^--- here
应该是
data: { chatroomid: '<?php echo $chatroomid; ?>'},
关于Jquery、Onclick 和 Ajax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15106793/