我的jsp引入了外部的js文件,但外部的脚本在本jsp页面不起作用,把外部的js文件放在本页才起效
<scripttype="text/javascript""src="javacript/count_perso.js"></script>count_perso.jsv...
<script type="text/javascript" "src="javacript/count_perso.js"></script>
count_perso.js
var ajax = null;
function InitAjax()
{
try {
ajax = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
ajax = false;
}
}
if (!ajax && typeof XMLHttpRequest!='undefined') {
ajax = new XMLHttpRequest();
}
return ajax;
}
function Count()
{
ajax = InitAjax();
var msg = document.getElementById("onlineCount");
var url = "public/count_person.jsp";
ajax.open("POST", url, true);
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajax.send(null);
ajax.onreadystatechange =function (){
if (ajax.readyState == 4 && ajax.status == 200) {
msg.innerHTML = ajax.responseText;
}
}
}
window.setInterval("Count()",1000*3);
上面这个js文件没有任何错误,不用检查
public文件夹下的count_person.jsp如下:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%
out.println(application.getAttribute("onlineCount"));
%>
</body>
</html>
是怎么回事
我想问引用的JS文件怎么不起作有 展开
count_perso.js
var ajax = null;
function InitAjax()
{
try {
ajax = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
ajax = false;
}
}
if (!ajax && typeof XMLHttpRequest!='undefined') {
ajax = new XMLHttpRequest();
}
return ajax;
}
function Count()
{
ajax = InitAjax();
var msg = document.getElementById("onlineCount");
var url = "public/count_person.jsp";
ajax.open("POST", url, true);
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajax.send(null);
ajax.onreadystatechange =function (){
if (ajax.readyState == 4 && ajax.status == 200) {
msg.innerHTML = ajax.responseText;
}
}
}
window.setInterval("Count()",1000*3);
上面这个js文件没有任何错误,不用检查
public文件夹下的count_person.jsp如下:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%
out.println(application.getAttribute("onlineCount"));
%>
</body>
</html>
是怎么回事
我想问引用的JS文件怎么不起作有 展开
4个回答
展开全部
就连外部的js文件都没看到引用到jsp页面中,怎么让js起作用啊???
<script type="text/javascript" src="js路劲"></script>像这样把js引用到页面来就可以了;希望对你有用了
<script type="text/javascript" src="js路劲"></script>像这样把js引用到页面来就可以了;希望对你有用了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
问题描述实在不清楚,你的jsp里引用到那个js文件了么?还有第一行<script type="text/javascript" "src="javacript/count_perso.js"></script>
src前面多了个"
src前面多了个"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你的ID在哪里....?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询