这是 chrome 浏览器抛出的消息错误,它在 IExplorer 和 FireFox 中运行良好
$ XMLHttpRequest cannot load file:///C:/Users/Lew/Documents/Human%20Staff/students.xml. Origin null is not allowed by Access-Control-Allow-Origin.
....如果已经定义了变量,我不知道为什么它不起作用...
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]
有什么想法可以解决吗?
这是一段代码:
<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();