¡Funciona!
Con el código siguiente va perfecto:
Código:
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<script type="application/javascript">
function loadJSON()
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
// Parse the JSON data structure contained in xmlhttp.responseText using the JSON.parse function.
var JSONObject = JSON.parse(xmlhttp.responseText);
// The JSONObject variable now contains the data structure and can be accessed as JSONObject.firstName and
// JSONObject.lastName. Assign the object members to the DOM elements FirstName and LastName so that they get
// displayed on the page
document.getElementById("FirstName").innerHTML = JSONObject.language;
document.getElementById("LastName").innerHTML = JSONObject.isbn;
}
}
xmlhttp.open("GET","http://pere.bocairent.net/z39.php?title=caballos",true);
xmlhttp.send();
}
</script>
<title>JSON and AJAX</title>
</head>
<body>
<div id="FirstName">Prince</div>
<div id="LastName">Vivian</div>
<button type="button" onclick="loadJSON()">Update Name</button>
<h2>Click this button to update the page</h2>
</body>
</html>
GET READY TO THE NEXT FIGHT!
Gracias a todos. Marco como solucionado.