a标签调用函数 is not defined
<script>
$(document).ready(function(){
function viewReceiveMessageDT(messageId,pageNow){
var ajaxurl = "/ett20/study/service/message/myinfo_viewReceiveMessage.jsp?messageId="+messageId+"&pageNow="+pageNow;
//$('#boxcontext').empty();
//$('#boxcontext').html("正在处理数据...请稍后");
$.ajax({
type : "get",
url : ajaxurl,
cache : false,
global : false,
success : function(data) {
$('#boxcontext').empty();
$('#boxcontext').html(data);
}
});
}
});
</script>
<a href="javascript:viewReceiveMessageDT(<%=rMessage.getMessageId()%>,0)" title='查看具体内容' ><%=rMessage.getSubject()%></a><br/>
页面报ReferenceError: viewReceiveMessageDT is not defined
javascript:viewReceiveMessageDT(67916002,0)
Line 1
请问这是为啥啊????????????????
------解决方案--------------------不要把函数放在$(document).ready(function(){});里面
把<script/>标签放到页面的尾部,养成写html的好习惯!
要理解html是怎么去加载和解析<script/>中的内容
------解决方案--------------------帮你改造一下:
<script>
function viewReceiveMessageDT(messageId,pageNow){
var ajaxurl = "/ett20/study/service/message/myinfo_viewReceiveMessage.jsp?messageId="+messageId+"&pageNow="+pageNow;
//$('#boxcontext').empty();
//$('#boxcontext').html("正在处理数据...请稍后");
$.ajax({
type : "get",
url : ajaxurl,
cache : false,
global : false,
success : function(data) {
$('#boxcontext').empty();
$('#boxcontext').html(data);
}
</script>
body部分:
<a href="#" onclick="viewReceiveMessageDT(<%=rMessage.getMessageId()%>,0)" title='查看具体内容' ><%=rMessage.getSubject()%></a>