Hello! I have an Ajax script wich works well on a page, but when I use it in another page I got the error "function not defined"
this one works well :
But when I put it in this page (I give the entier page here after) i got the "not defined" error:
do somenone see what is happening with my code ?
thx a lot
this one works well :
Code:
<script type="text/javascript">
function details(var1, var2)
{
var html;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
h = document.getElementById("log").innerHTML;
h = h + xmlhttp.readyState + " / " + xmlhttp.status + "<br/>";
if(xmlhttp.readyState==4 && (xmlhttp.status==200||xmlhttp.status==0))
{
html = xmlhttp.responseText;
document.getElementById("res").innerHTML=html;
}
}
xmlhttp.open("GET","detailsCity?Pays="+var1+"&Name="+var2,true);
xmlhttp.send();
}
</script>
Code:
<a href=""onMouseOver= "details('${CDet.res.name}','${CDet.res.cap}')"
onMouseOut="details('${CDet.res.name}','${CDet.res.cap}')">
${CDet.res.cap}</a><br>
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page
language="java"
contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
%>
<%@ page import="java.awt.*" %>
<jsp:useBean id="CList" scope="session" class="fr.n7.asi.cs.model.CLBean"></jsp:useBean>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="sts.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
function details(var1, var2)
{
var html;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
h = document.getElementById("log").innerHTML;
h = h + xmlhttp.readyState + " / " + xmlhttp.status + "<br/>";
if(xmlhttp.readyState==4 && (xmlhttp.status==200||xmlhttp.status==0))
{
html = xmlhttp.responseText;
document.getElementById("res").innerHTML=html;
}
}
xmlhttp.open("GET","detailsCity?Pays="+var1+"&Name="+var2,true);
xmlhttp.send();
}
</script>
<title>CountryList View (JSP)</title>
</head>
<body background="http://bytes.com/images/terres.jpeg">
Bonjour <% out.println(session.getAttribute("nom"));%> ! <a href="deconnect">se deconnecter</a><br><br><br>
<h1>LISTE DES PAYS COMMENCANT PAR PREFIXE</h1>
<table border="1">
<c:forEach var="citem" items="${CList.res}">
<tr><td>
<a href="details?Code=${citem.code}">${citem.name}</a><br/>
</td></tr>
</c:forEach>
<tr><td>
<a href=""onMouseOver= "details('aaaa','bbbb')"
onMouseOut="details('aaaa','aaaa')">
aaaaaa</a><br>
</td></tr>
</table>
<h3><a href="prefCreate.jsp">retour au menu principal</a><br/></h3>
</body>
</html>
thx a lot
Comment