Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/10/2012, 04:56
pepetpm
 
Fecha de Ingreso: febrero-2008
Mensajes: 12
Antigüedad: 16 años, 2 meses
Puntos: 0
Ejecutar javascripts dentro de ajax

Buenas tengo un problema que no se como hacer ejecutar un codigo javascript que viene de la respuesta de un ajax, espero que me podais ayudar. GRACIAS!!

prueba.html es donde creo la llamada.
Código:
<!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=utf-8" />
<title>Documento sin título</title>
<script type="text/javascript">
function llamarajax(idioma) {
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)  {
		  document.getElementById('mostrar').innerHTML=xmlhttp.responseText;
	  }
	}
	xmlhttp.open("GET","prueba2.html",true);
	xmlhttp.send();
	
}
</script>
</head>

<body>
<input type="button" id="boton" name="boton" value="mostrar" onclick="llamarajax()" />
<div id="mostrar"></div>
</body>
</html>

prueba2.html es el que cargo mediente ajax
Código:
contenido ajax
<script type="text/javascript">alert("hola");</script>