2013-02-27 66 views
1

我已经摆弄这个,绝对没有进展或运气。如果我拿出.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> 
+1

更改错误时'chatroomid:=“''to'chatroomid:'<?php echo $ chatroomid; ?>''所以减去'=' – 2013-02-27 07:57:21

回答

1
<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

2

只是寻找热塑成型吧..你有一个额外的=数据对象

data: { chatroomid: = '<?php echo $chatroomid; ?>'}, 
       ------^^--- here 

应该

data: { chatroomid: '<?php echo $chatroomid; ?>'}, 
+1

哦,哈哈哈!正在写PHP。是的,修好了,谢谢! – Rujikin 2013-02-27 08:00:33

+0

welocme ....快乐编码 – bipen 2013-02-27 08:01:28

1

错误在我看来:额外的“=”

chatroomid: = '<?php echo $chatroomid; ?>'}, 

我通常测试与jslint代码有这样一个