Ver Mensaje Individual
  #3 (permalink)  
Antiguo 28/01/2011, 11:08
faustofernandez86
 
Fecha de Ingreso: noviembre-2010
Ubicación: La Ceiba
Mensajes: 6
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: Cargar .js dentro de DIV

Buenas

Lo que podes hacer es incluir todos los script en web1.php asi estara cargado antes de que mostres web2.php. "<script type="text/javascript" src="archivo.js"></script>"

Código HTML:
<!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" lang="en" xml:lang="en">
<head>


<script type="text/javascript" src="archivo.js"></script>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Carga DIV Ajax</title>

<script language="javascript" src="jquery.js"></script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script language="javascript">
	function ajaxdiv(){
		$.ajax( {
			async:true,
			dataType: "html",
			type: "POST",
			url: "foro.php",
			data: "",
			global: true,
			ifModified: false,
			processData:true,
			contentType: "application/x-www-form-urlencoded",
			success: function(datos){
				$("#contenedor").html(datos)
				
			}
		});
}
		function ajaxdiv2(){
		$.ajax( {
			async:true,
			dataType: "html",
			type: "POST",
			url: "text.php",
			data: "",
			global: true,
			ifModified: false,
			processData:true,
			contentType: "application/x-www-form-urlencoded",
			success: function(datos){
				$("#contenedor").html(datos)
				
			}
		});
	}
</script>
<style type="text/css">
#menu{
float:left;
width:150px;
height: 400px;
border: 3px solid black;
padding: 5px;
padding-left: 8px;

}

#menu a{
padding: 3px 1px;
display: block;
width: 100%;
text-decoration: none;
font-weight: bold;
border-bottom: 1px solid gray;
}

#menu a:hover{
background-color: #FFFF80;
}

#contenedor{
float:left;
width:950px;
min-height: 400px;
border: 3px solid black;
margin-left: 10px;
padding: 5px;
padding-bottom: 8px;
}

* html #contenedor{ /*IE only style*/
height: 400px;
}
</style>
</head>

<body>
<div id="menu">
<a href="javascript:ajaxdiv();">Menu 1</a>
<br>
<a href="javascript:ajaxdiv2();">Menu 2</a>
</div>

<div id="contenedor"><h3>Prova!</h3></div>

</body>

</html> 

Última edición por faustofernandez86; 28/01/2011 a las 11:14