this is the message error throwed for the chrome browser, and it works very well in IExplorer and FireFox
$ XMLHttpRequest cannot load file:///C:/Users/Lew/Documents/Human%20Staff/students.xml. Origin null is not allowed by Access-Control-Allow-Origin.
…. I dont know why it doesnt work if already defined the variables…
another error mesagge throwed by the developer tool by chrome:
$nombre: [Exception: ReferenceError: telefono is not defined]
$edad : [Exception: ReferenceError: telefono is not defined]
$telefono : [Exception: ReferenceError: telefono is not defined]
$carnet : [Exception: ReferenceError: telefono is not defined]
any idea to fixed?
This is a code snipped:
<pre><code>
// JavaScript Document
// File: leerXML.js
$(document).ready(function(){
$("#ContentArea").ready(function(){
$.get("students.xml",{},function(xml){ //Abrimos el archivo students.xml
// Crearemos un string HTML
HTMLcontent = '<br/><br/>';
HTMLcontent += '<table width="70%" border="1" cellpadding="0" cellspacing="0">';
HTMLcontent += '<th>Nombre</th><th>Edad</th><th>Telefono</th><th>Carnet</th>';
$('estudiante',xml).each(function(i) {
var nombre ='';
var edad='';
var telefono='';
var carnet='';
nombre = $(this).find("nombre").text();
edad = $(this).find("edade").text();
telefono = $(this).find("telefono").text();
carnet = $(this).find("carnet").text();
You can’t do this because you’re loading the website from a local filesystem. You need to run a web server in order to cross-origin request (the filesystem has an origin of null because it has no domain, and that is never permitted to make a cross origin request).
Set up a tiny web server and serve your files from that in order to test. See http://code.google.com/p/chromium/issues/detail?id=40787.