作者martone (Krel)
看板Ajax
标题[问题] 初碰JQUERY AJAX 麻烦指教一下
时间Fri Oct 31 21:28:07 2008
目前使用jQuery的ajax,可是却得不到回传值。请各位指教一下
在header里
<script type="text/javascript" src="js/jquery-1.2.6.js"></script>
<script type="text/javascript">
function showMsg(e) {
$(e.target).attr('disabled', true);
$.ajax({
url: '
http://127.0.0.1:8081/KH/forajax.jsp',
error: function(xhr) {
alert('Ajax request 发生错误');
},
success: function(response) {
$('#msg').html('demoOK');
}
});
}
function msg2(e){
$('#msg').html('comeFrom2');}
</script>
有个按钮
<input type="button" value="Click Me" onclick="showMsg()"/>
我的jsp内有
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="
http://java.sun.com/jsp/jstl/core" %>
<c:out value="demook"></c:out>
第一次使用ajax,却不知道失败原因在哪,就取不到回传值
请各位帮忙看一下 谢谢^^
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.170.127.2
※ 编辑: martone 来自: 118.170.127.2 (10/31 21:31)
1F:推 tn801534:回传的就放在response阿就是success的第一个参数 10/31 22:40
2F:→ martone:原本是用$('#msg').html(response)但发现没回传demook 10/31 22:49
3F:→ martone:所以才在里面放字串,结果也是没有出现comeFrom2 10/31 22:50
4F:推 tn801534:你可以装firebug debug ajax.. 10/31 22:56