Qual seria a maneira correta? Javascript

PHP

Java

.NET

16/04/2016

Gostaria de exibir o conteúdo presente na class example do arquivo texto.html, mas mostra conteúdo vazio.

index.html

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	
	<title>Exemplo 1 − Carregar Arquivo do Servidor </title>

	<script src="https://code.jquery.com/jquery-1.10.2.js"></script>

	<script type="text/javascript">
	if(window.XMLHttpRequest){
	variavelhtttp = new XMLHttpRequest();
	}else{
	alert("Seu navegador não tem suporte para a tecnica Ajax!");
	}
	</script>

</head>

<body>

	<button type="button" onclick="loadDoc()">realizar função</button>

	<script type="text/javascript">
		function loadDoc(){
			variavelhtttp= new XMLHttpRequest();
			variavelhtttp.open("GET","texto.html",false);
			variavelhtttp.send();
			alert(  $( ".example" ).text() );
		 }
	</script>

</body>
</html>


texto.html

<html>
<head>
	<title></title>
</head>
<body>
	<div class="example">Hello World.</div>
</body>
</html>
Foxtery

Foxtery

Curtidas 0
POSTAR