Jquery,Onclick和Ajax
问题描述:
我已经摆弄这个,绝对没有进展或运气。如果我拿出.ajax,它可以正常工作,但是.ajax什么都不会触发,甚至没有随机测试警报。你能看到我做错了吗?我试图遵循Jquery文档。 PHP的作品。Jquery,Onclick和Ajax
<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>
答
<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>
ü可以试试这个代码
+0
这是等号是XD的问题; – Rujikin 2013-02-27 08:01:12
更改错误时'chatroomid:=“''to'chatroomid:'''所以减去'=' –
2013-02-27 07:57:21