I've a xml file with 10 "item entries" in the following format:
<channel>
<title>Search products</title>
<link>http://v2-bienaldolivrosp.rxnova.com/feeds/search/Products/?startRecord=1</link>
<description>Bienal do Livro de Sao Paulo search</description>
<language>pt-BR</language>
<item>
<guid isPermaLink="true">http://www.bienaldolivrosp.com.br/pt-BR/Exhibitors/376354/Manole-Conteudo/Products/716223/Gestao-de-Pessoas-4-ed-O-Novo-Papel-dos-Recursos-Humanos-nas-Organizacoes</guid>
<link>http://www.bienaldolivrosp.com.br/pt-BR/Exhibitors/376354/Manole-Conteudo/Products/716223/Gestao-de-Pessoas-4-ed-O-Novo-Papel-dos-Recursos-Humanos-nas-Organizacoes</link>
<title>Gestão de Pessoas 4ª ed. - O Novo Papel dos Recursos Humanos nas Organizações</title>
<description>A obra parte dos novos desafios da gestão de pessoas e direciona a atenção do leitor para seis ações que, inerentemente, se conectam em rede: agregar, recompensar, desenvolver, monitorar, manter e, por fim, aplicar pessoas. </description>
<pubDate>Fri, 25 Jul 2014 20:17:53 Z</pubDate>
<enclosure url="http://www.bienaldolivrosp.com.br/__novaimages/596889" type="image/jpg" length="1000" />
</item>
</channel>
I'm running the following code to parse the xml:
for (i = 0; i < values.length; i++) {
text += values[i]['title'] + " - " + "<br>";
}
The above code works fine but the problem is that I need to get the url inside de "enclosure url" node and I can't figure out how to do it.
Any help?
Try this one:
text +=
values[i]['title'] + " - " +
values[i]['enclosure'].getAttribute('url') +
" - " +
"<br>"
;
I may be wrong but... ^_^
I expect it will give output like:
"Gestão de Pessoas 4ª ed. - O Novo Papel dos Recursos Humanos nas Organizações - http://www.bienaldolivrosp.com.br/__novaimages/596889 - <br>"
Version 0.2:
text += values[i]['title'] + " - ";
if ( typeof values[i]['enclosure'] === 'undefined' ) {
text += 'Undefined Enclosure';
} else {
console.log( values[i]['enclosure'] );
text += values[i]['enclosure'].getAttribute('url');
}
Related
Using while loop, I want to alert names with their number from an array. I also have to put every name in a single alert.
Script:
var voetbalteam = 1;
var spelers = ["Nobert Alblas", "Kostas Lamprou", "André Onana", "Benjamin van Leer", "Léon Bergsma", "Damil Dankerlui", "Matthijs de Ligt", "Mitchell Dijks", "Luis Orejuela", "Daley Sinkgraven", "Joël Veltman", "Nick Viergever", "Max Wöber", "Deyovaisio Zeefuik", "Frenkie de Jong", "Siem de Jong", "Carel Eiting", "Noussair Mazaoui", "Lasse Schöne", "Donny van de Beek", "Klaas Jan Huntelaar", "Kasper Dolberg", "Justin Kluivert"];
while ((voetbalteam <= 23) + (spelers >= 0)){
alert("Ik ben " + spelers[spelers] + " En ik ben de " + voetbalteam + "e speler.");
spelers ++;
voetbalteam ++;
}
Use forEach() to loop over the array.
var voetbalteam = 1;
var spelers = ["Nobert Alblas", "Kostas Lamprou", "André Onana", "Benjamin van Leer", "Léon Bergsma", "Damil Dankerlui", "Matthijs de Ligt", "Mitchell Dijks", "Luis Orejuela", "Daley Sinkgraven", "Joël Veltman", "Nick Viergever", "Max Wöber", "Deyovaisio Zeefuik", "Frenkie de Jong", "Siem de Jong", "Carel Eiting", "Noussair Mazaoui", "Lasse Schöne", "Donny van de Beek", "Klaas Jan Huntelaar", "Kasper Dolberg", "Justin Kluivert"];
spelers.forEach(function(key, value){
console.log("Ik ben " + key + " En ik ben de " + (value + 1) + "e speler.");
});
Using a while loop, use voetbalteam as an iterator and increment it inside the while loop.
var voetbalteam = 0;
var spelers = ["Nobert Alblas", "Kostas Lamprou", "André Onana", "Benjamin van Leer", "Léon Bergsma", "Damil Dankerlui", "Matthijs de Ligt", "Mitchell Dijks", "Luis Orejuela", "Daley Sinkgraven", "Joël Veltman", "Nick Viergever", "Max Wöber", "Deyovaisio Zeefuik", "Frenkie de Jong", "Siem de Jong", "Carel Eiting", "Noussair Mazaoui", "Lasse Schöne", "Donny van de Beek", "Klaas Jan Huntelaar", "Kasper Dolberg", "Justin Kluivert"];
while (voetbalteam < spelers.length){
console.log("Ik ben " + spelers[voetbalteam] + " En ik ben de " + (voetbalteam + 1) + "e speler.");
voetbalteam ++;
}
consider using console.log() instead of alert() when you are coding.
alert() is blocking
alert() cannot be easily suppressed in non-debug environment
console typically formats your objects nicely and allows to traverse
them
logging statements often have an interactive pointer to code which
issued logging statement
you cannot look at more than one alert() message at a time
consoles can have different logging levels with intuitive formatting
The above text was taken from here
If you really want to use a while loop, try this:
var voetbalteam = 0;
var spelers = ["Nobert Alblas", "Kostas Lamprou", "André Onana", "Benjamin van Leer", "Léon Bergsma", "Damil Dankerlui", "Matthijs de Ligt", "Mitchell Dijks", "Luis Orejuela", "Daley Sinkgraven", "Joël Veltman", "Nick Viergever", "Max Wöber", "Deyovaisio Zeefuik", "Frenkie de Jong", "Siem de Jong", "Carel Eiting", "Noussair Mazaoui", "Lasse Schöne", "Donny van de Beek", "Klaas Jan Huntelaar", "Kasper Dolberg", "Justin Kluivert"];
while (voetbalteam < spelers.length){
alert("Ik ben " + spelers[voetbalteam] + " En ik ben de " + (voetbalteam + 1) + "e speler.");
voetbalteam++;
}
I have documents in which i need to highlight that a person was quoted. So I'm looking for all text that's enclosed by quotes...I'm using the below code, which works but it only captures the first occurence..
var str = 'L\'armée sud-coréenne accuse la Corée du Nord d\'avoir lancé \"plusieurs\" missiles \"balistiques interdits qui ont franchi une distance\" d\'environ 1000 kilomètres avant de tomber au \"large de la côte est du pays communiste.\" '
var reg = new RegExp(/"(.*?)"/);
var matches = str.match(reg);
for (var i = 0; i < matches.length; i++) {
var s = matches[i];
str = str.replace(matches[i], '<span style="color:blue">' + matches[i] + '</span>');
matches[i] = s;
}
Make your Regex global:
The g modifier is used to perform a global match (find all matches rather than stopping after the first match).
var str = 'L\'armée sud-coréenne accuse la Corée du Nord d\'avoir lancé \"plusieurs\" missiles \"balistiques interdits qui ont franchi une distance\" d\'environ 1000 kilomètres avant de tomber au \"large de la côte est du pays communiste.\" '
var reg = new RegExp(/"(.*?)"/g); //notice /g, making the expression global
var matches = str.match(reg);
for (var i = 0; i < matches.length; i++) {
var s = matches[i];
str = str.replace(matches[i], '<span style="color:blue">' + matches[i] + '</span>');
matches[i] = s;
}
document.getElementById("myDiv").innerHTML = str;
Making your expression global guarantees all instances of the quotes match.
JSFiddle: https://jsfiddle.net/zjxjub96/
To illustrate what #Casimir says in his comment, here is a little example:
var str = 'L\'armée sud-coréenne accuse la Corée du Nord d\'avoir lancé \"plusieurs\" missiles \"balistiques interdits qui ont franchi une distance\" d\'environ 1000 kilomètres avant de tomber au \"large de la côte est du pays communiste.\" '
str = str.replace(/"(.*?)"/g, '<span style="color:blue">$&</span>')
document.getElementById("myDiv").innerHTML = str;
<div id="myDiv">
</div>
Notice that this way is easier, and doesn't require a for loop.
JSFiddle: https://jsfiddle.net/zjxjub96/1/
I've searching and trying other suggestions in StackOverflow.
Unfortunately the answers are not working for me. They are suggesting to use 'foreach' instead of 'for', but how could I... if I want to iterate just 50 times? :<
Well, I'll just paste the code and let's see if some good folk can help me.
JSLint was unable to finish.
Unexpected 'for'. for (var i=1;i<=50;i+=1){
line 6 column 8
Unexpected 'var'. for (var i=1;i<=50;i+=1){
line 6 column 13
"use strict";
var campo = [];
var ronda = 0;
// Llenamos el campo de 50 humanos/maquinas/extraterrestres = 150 jugadores
for (var i=1;i<=50;i+=1){
campo.push(new Human("h"+i));
campo.push(new Machine("m"+i));
campo.push(new Alien("e"+i));
}
// Array.prototype.suffle para barajar el Array
Array.prototype.shuffle = function() {
var input = this;
for (var i=input.length-1;i>=0;i-=1){
var randomIndex = Math.floor(Math.random()*(i+1));
var itemAtIndex = input[randomIndex];
input[randomIndex]=input[i];
input[i] = itemAtIndex;
}
};
// Barajamos el Array campo
campo.shuffle();
// Comprobamos que quedan más de 1 jugador por ronda
while (campo.length>1) {
console.log("Iniciando ronda: " + ++ronda);
console.log(campo.length + " jugadores luchando.");
// Recorremos el campo, y luchamos
var muertos = 0;
for (var i=0; i<campo.length-1; i+=2){
// Caso de numero impar de jugadores:
// Por ejemplo cuando solo quedan 3 jugadores. Pelean 1 vs 2. El 3 se libra.
// - Si siguen vivos y aguantan otra ronda, se barajan las posiciones otra vez y
// vuelven a pelear dos. Y el nuevo tercero no pelea.
// - Si uno de los dos muere, en la siguiente ronda ya solo quedan 2, y pelean normal.
campo[i].fight(campo[(i+1)]);
// # descomentar solo la siguiente linea para hacer comprobaciones #
// console.log("["+ campo[i].username + "] VS ["+ campo[(i+1)].username + "]");
if (campo[i].health<=0) {
console.log("El " + campo[i].constructor.name + " llamado " + campo[i].showName() + " ha sido asesinado :<");
var fallecido = campo.splice(i, 1);
// # descomentar solo la siguiente linea para hacer comprobaciones #
//console.log(fallecido[0]);
i--; // como el array se hace pequeño, hay que corregir el error para que no se salte jugadores
muertos++;
} else {
if (campo[(i+1)].health<=0) {
console.log("El " + campo[(i+1)].constructor.name + " llamado " + campo[(i+1)].showName() + " ha sido asesinado :<");
var fallecido = campo.splice((i+1), 1);
// # descomentar solo la siguiente linea para hacer comprobaciones #
// console.log(fallecido[0]);
i--; // como el array se hace pequeño, hay que corregir el error para que no se salte jugadores
muertos++;
}
else {
// # descomentar solo la siguiente linea para hacer comprobaciones #
// console.log("Siguen vivos");
}
}
}
console.log("Fin de ronda!")
if (muertos === 1) {
console.log("Ha muerto " + muertos + " jugador.");
} else {
console.log("Han muerto " + muertos + " jugadores.");
}
// Al final de la ronda barajamos de nuevo
campo.shuffle();
}
if (campo.length === 1) {
console.log("Vaya!! Ha sido una memorable batalla!");
console.log("Después de tantos bits derramados y de " + ronda + " rondas... el jugador '" + campo[0].constructor.name + "' llamado '" + campo[0].showName() + "' se ha alzado con la victoria!!");
}
There are some other for in the code, but It seems to stop at the first one.
Thank you in advance!
Forgot to say, the code works PERFECT. But I was just validating it with JSLint, also 'tolerating' for warnings in JSLint doesn't work.
When you choose to tolerate for, the next thing it's warning you about is the global declaration of the var i. Since you've got the for-loop at the top-level, i becomes available everywhere in your program.
I'd just tolerate for and wrap it up an in IIFE. That way, i is only available inside this function, and doesn't leak out to the global scope.
(function() {
var i = 0;
for (i=1;i<=50;i+=1) {
campo.push(new Human("h"+i));
campo.push(new Machine("m"+i));
campo.push(new Alien("e"+i));
}
})();
You could also, barring using an existing implementation out there, create a function that generalizes the "repeat n times" definition.
function repeat(fn, n) {
var i = 0;
for (;i < n; i += 1) {
fn();
}
}
Use in your case would look like:
function initialize() {
campo.push(new Human("h"+i));
campo.push(new Machine("m"+i));
campo.push(new Alien("e"+i));
}
// then later
repeat(initialize, 50);
jslint is being overzealous (some would say), it expects all var statements to be at the top of a function.
You can tell jslint that you don't care about that rule by adding an instruction comment on the line above where you are declaring the variable.
// Llenamos el campo de 50 humanos/maquinas/extraterrestres = 150 jugadores
/*jslint for:true */
for (var i=1;i<=50;i+=1){
Or you can move all your var i; to the top of the file/function
Good afternoon, I am developing a small script that analyzes the DOM of an HTML page and write on screen the tree of nodes.
It is a simple function that is called recursively for get all nodes and their children. The information for each node is stored in an array (custom object).
I have gotten get all the nodes in the DOM, but not how to paint in a tree through nested lists.
JSFIDLE
https://jsfiddle.net/06krpdyh/
HTML
<html>
<head>
<title>Formulario para validar</title>
<script type="text/javascript" src="actividad_1.js">Texto script</script>
</head>
<body>
<p>Primer texto que se visualiza en la Pagina</p>
<div>Esto es un div</div>
<div>Otro div que me encuentro</div>
<p>Hay muchos parrafos</p>
<ul>
<li>Lista 1</li>
<li>Lista 2</li>
<li>Lista 3</li>
</ul>
<button type="button" id="muestra_abol">Muestra Arbol DOM</button>
</body>
</html>
JS
// Ejecuta el script una vez se ha cargado toda la página, para evitar que el BODY sea NULL.
window.onload = function(){
// Evento de teclado al hacer click sobre el boton que muestra el arbol.
document.getElementById("muestra_abol").addEventListener("click", function(){
muestraArbol();
});
// Declara el array que contendrá los objetos con la información de los nodos.
var nodeTree = [];
// Recoge el nodo raíz del DOM.
var obj_html = document.documentElement;
// Llama a la función que genera el árbol de nodos de la página.
getNodeTree(obj_html);
console.log(nodeTree);
// Función que recorre la página descubriendo todo el árbol de nodos.
function getNodeTree(node)
{
// Comprueba si el nodo tiene hijos.
if (node.hasChildNodes())
{
// Recupera la información del nodo.
var treeSize = nodeInfo(node);
// Calcula el índice del nodo actual.
var treeIndex = treeSize - 1;
// Recorre los hijos del nodo.
for (var j = 0; j < node.childNodes.length; j++)
{
// Comprueba, de forma recursiva, los hijos del nodo.
getNodeTree(node.childNodes[j]);
}
}
else
{
return false;
}
}
// Función que devuelve la información de un nodo.
function nodeInfo(node,)
{
// Declara la variable que contendrá la información.
var data = {
node: node.nodeName,
parent: node.parentNode.nodeName,
childs: [],
content: (typeof node.text === 'undefined'? "" : node.text)
}
var i = nodeTree.push(data);
return i;
}
// Función que devuelve los datos de los elementos hijos de un nodo.
function muestraArbol()
{
var txt = "";
// Comprueba si existen nodos.
if (nodeTree.length > 0)
{
// Recorre los nodos.
for (var i = 0; i < nodeTree.length; i++)
{
txt += "<ul><li>Nodo: " + nodeTree[i].node + "</li>";
txt += "<li> Padre: " + nodeTree[i].parent + "</li>";
txt += "<li>Contenido: " + nodeTree[i].content + "</li>";
txt += "</ul>";
}
document.write(txt);
}
else
{
document.write("<h1>No existen nodos en el DOM.</h1>");
}
}
};
Does anyone comes up how to draw a nested tree to glance at the parent and child nodes you distinguish?
Greetings and thank you
You have a recursive DOM reader, but you also need a recursive outputter. You're also dealing with a one dimensional array when you need a multi-level object (tree).
We'll start with refactoring getNodeTree. Instead of adding to a global array (nodeTree in your code), let's have it return a tree:
function getNodeTree (node) {
if (node.hasChildNodes()) {
var children = [];
for (var j = 0; j < node.childNodes.length; j++) {
children.push(getNodeTree(node.childNodes[j]));
}
return {
nodeName: node.nodeName,
parentName: node.parentNode.nodeName,
children: children,
content: node.innerText || "",
};
}
return false;
}
Same for muestraArbol (for our monolingual friends out there, it means "show tree"): We'll have it work recursively and return a string containing nested lists:
function muestraArbol (node) {
if (!node) return "";
var txt = "";
if (node.children.length > 0) {
txt += "<ul><li>Nodo: " + node.nodeName + "</li>";
txt += "<li> Padre: " + node.parentName + "</li>";
txt += "<li>Contenido: " + node.content + "</li>";
for (var i = 0; i < node.children.length; i++)
if (node.children[i])
txt += "<li> Hijos: " + muestraArbol(node.children[i]) + "</li>";
txt += "</ul>";
}
return txt;
}
Finally, if we put it together in a snippet:
var nodeTree = getNodeTree(document.documentElement);
console.log(nodeTree);
function getNodeTree(node) {
if (node.hasChildNodes()) {
var children = [];
for (var j = 0; j < node.childNodes.length; j++) {
children.push(getNodeTree(node.childNodes[j]));
}
return {
nodeName: node.nodeName,
parentName: node.parentNode.nodeName,
children: children,
content: node.innerText || "",
};
}
return false;
}
function muestraArbol(node) {
if (!node) return "";
var txt = "";
if (node.children.length > 0) {
txt += "<ul><li>Nodo: " + node.nodeName + "</li>";
txt += "<li> Padre: " + node.parentName + "</li>";
txt += "<li>Contenido: " + node.content + "</li>";
for (var i = 0; i < node.children.length; i++)
if (node.children[i])
txt += "<li> Hijos: " + muestraArbol(node.children[i]) + "</li>";
txt += "</ul>";
}
return txt;
}
document.getElementById("muestra_abol").addEventListener("click", function() {
document.getElementById("result").innerHTML = muestraArbol(nodeTree);
});
<title>Formulario para validar</title>
<body>
<p>Primer texto que se visualiza en la Pagina</p>
<div>Esto es un div</div>
<div>Otro div que me encuentro</div>
<p>Hay muchos parrafos</p>
<ul>
<li>Lista 1</li>
<li>Lista 2</li>
<li>Lista 3</li>
</ul>
<button type="button" id="muestra_abol">Muestra Arbol DOM</button>
<div id="result"></div>
</body>
Finally: My apologies, for my Spanish-JavaScript reading skills are not in their prime. :)
$.ajax({
url : SrvHandlerCalendar,
type : 'post',
data : {"persona": str, "day2" : dia + '.' + mes + '.' + anio},
timeout : 2000,
tryCount : 0,
retryLimit : 3,
cache: false,
dataType: ($.browser.msie) ? "text" : "xml",
success: function(data) {
var xml;
if (typeof data == 'string') {
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.loadXML(data);
} else {
xml = data;
}
$(xml).find('evento').each(function(){
ai++;
var id = $(this).attr('id');
var rdia = $(this).find('dia').text();
var rmes = $(this).find('mes').text();
var ranio = $(this).find('anio').text();
var hora = $(this).find('hora').text();
var horario = $(this).find('horario').text();
var desc = $(this).find('d').text();
var estado = $(this).find('estado').text();
var localidad = $(this).find('localidad').text();
var colonia = $(this).find('colonia').text();
var calle = $(this).find('calle').text();
var numero = $(this).find('ncasa').text();
var telefono = $(this).find('telefono').text();
var celular = $(this).find('celular').text();
var persona = $(this).find('persona').text();
var creador = $(this).find('creador').text();
var observaciones = $(this).find('observaciones').text();
if(persona != $("#personas_select option:selected").text()) return 1;
var html = "<font size=5>Informacion del evento con <u>" + persona + "</u></font><br>";
html += "<font size=2>"+desc+"</font><br><br><br>";
html += "<table class=\"datatable\" cellpadding=10>"
html += "<tr><td><strong>Hora de la Cita</strong></td><td>" + hora + horario+"</td></tr>";
html += "<tr><td><strong>Domicilio</strong></td><td>" + calle + " #"+numero+"</td></tr>";
html += "<tr><td><strong>Colonia</strong></td><td>" +colonia+"</td></tr>";
//html += "<tr colspan=\"2\" style=\"text-align: center;\"><td>Datos de contacto</td></tr>";
html += "<tr><td><strong>Telefono</strong></td><td>" + telefono +"</td></tr>";
html += "<tr><td><strong>Celular</strong></td><td>" + celular +"</td></tr>";
html += "<tr><td><strong>Encuestador</strong></td><td>" + creador +"</td></tr>"
html += "<tr><td><strong>Observaciones</strong></td><td>" + observaciones +"</td></tr></table>";
$('#datos').html(html);
/*
var html = "<font size=5>Informacion del evento con <u>" + persona + "</u></font><br>";
html += "<font size=2>"+desc+"</font><br>";
html += "<table>"
html += " <tr> <td>Hora de la Cita</td><td>horario y fecha</td></tr>";
html += "<tr> <td>Domicilio</td><td>vdomicilio</td></tr>";
html += "<tr><td>Colonia</td><td>vcolonia</td></tr>";
html += "<tr><td>Datos de contacto</td><td>(no hay otra columna)</td></tr>";
html += "<tr><td>telefono</td><td></td></tr>";
html += "<tr><td>celular</td><td></td></tr>";
html += "<tr><td>encuestador</td><td></td></tr></table>";
*/
});
if($("#datos").html() == loading){
$('#datos').html("Uups! No hay datos de evento para esta persona. <strong>Notificar de inmediato al administrador del sistema</strong> <a href=\"#\" onclick='alert(\"No se encontro el primer atributo XML\" + \" "+" \" )'> Ficha Técnica</a>");
}
},
error : function(xhr, textStatus, errorThrown ) {
if (textStatus == 'timeout') {
$('#datos').html(loading);
this.tryCount++;
if (this.tryCount <= this.retryLimit) {
//try again
$.ajax(this);
return;
}
$('#datos').html("Uups! Hubo un error procesando su solicitud <a href=\"#\" onclick='alert(\"Respuesta HTTP: \" + \" "+ xhr.status+" \" + \"\\nManejador del servidor: \" + \" " + SrvHandlerCalendar + " \" + \"\\nDescripcion de error: \" + \" " + textStatus + " \" + \"\\nIntentos: \" + \" " + this.retryLimit + " \" )'> Ficha Técnica</a>");
return;
}
if (xhr.status == 500) {
$('#datos').html('Uups! Hubo un error con el servidor. Intente nuevamente mas tarde y pongase en contacto con el administrador de sistemas.');
} else {
$('#datos').html("Uups! Hubo un error procesando su solicitud <a href=\"#\" onclick='alert(\"Respuesta HTTP: \" + \" "+ xhr.status+" \" + \"\\nManejador del servidor: \" + \" " + SrvHandlerCalendar + " \" + \"\\nDescripcion de error: \" + \" " + textStatus + " \" )'> Ficha Técnica</a>");
}
}
});`
And basically this:
var xml;
if (typeof data == 'string') {
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.loadXML(data);
} else {
xml = data;
}
$(xml).find('evento').each(function(){
ai++;
var id = $(this).attr('id');
var rdia = $(this).find('dia').text();
var rmes = $(this).find('mes').text();
var ranio = $(this).find('anio').text();
var hora = $(this).find('hora').text();
var horario = $(this).find('horario').text();
var desc = $(this).find('d').text();
var estado = $(this).find('estado').text();
var localidad = $(this).find('localidad').text();
var colonia = $(this).find('colonia').text();
var calle = $(this).find('calle').text();
var numero = $(this).find('ncasa').text();
var telefono = $(this).find('telefono').text();
var celular = $(this).find('celular').text();
var persona = $(this).find('persona').text();
var creador = $(this).find('creador').text();
var observaciones = $(this).find('observaciones').text();
if(persona != $("#personas_select option:selected").text()) return 1;
var html = "<font size=5>Informacion del evento con <u>" + persona + "</u></font><br>";
html += "<font size=2>"+desc+"</font><br><br><br>";
html += "<table class=\"datatable\" cellpadding=10>"
html += "<tr><td><strong>Hora de la Cita</strong></td><td>" + hora + horario+"</td></tr>";
html += "<tr><td><strong>Domicilio</strong></td><td>" + calle + " #"+numero+"</td></tr>";
html += "<tr><td><strong>Colonia</strong></td><td>" +colonia+"</td></tr>";
//html += "<tr colspan=\"2\" style=\"text-align: center;\"><td>Datos de contacto</td></tr>";
html += "<tr><td><strong>Telefono</strong></td><td>" + telefono +"</td></tr>";
html += "<tr><td><strong>Celular</strong></td><td>" + celular +"</td></tr>";
html += "<tr><td><strong>Encuestador</strong></td><td>" + creador +"</td></tr>"
html += "<tr><td><strong>Observaciones</strong></td><td>" + observaciones +"</td></tr></table>";
$('#datos').html(html);
/*
var html = "<font size=5>Informacion del evento con <u>" + persona + "</u></font><br>";
html += "<font size=2>"+desc+"</font><br>";
html += "<table>"
html += " <tr> <td>Hora de la Cita</td><td>horario y fecha</td></tr>";
html += "<tr> <td>Domicilio</td><td>vdomicilio</td></tr>";
html += "<tr><td>Colonia</td><td>vcolonia</td></tr>";
html += "<tr><td>Datos de contacto</td><td>(no hay otra columna)</td></tr>";
html += "<tr><td>telefono</td><td></td></tr>";
html += "<tr><td>celular</td><td></td></tr>";
html += "<tr><td>encuestador</td><td></td></tr></table>";
*/
});
if($("#datos").html() == loading){
$('#datos').html("Uups! No hay datos de evento para esta persona. <strong>Notificar de inmediato al administrador del sistema</strong> <a href=\"#\" onclick='alert(\"No se encontro el primer atributo XML\" + \" "+" \" )'> Ficha Técnica</a>");
}
Only works on Chrome/Firefox and Not on IE.
I don't know why, I googled about JQuery and IE errors, tried the 'fixes' and they still do not work.
Thank you in advance.
UPDATE
It now works.
The problem with IE is that the XML It was receiving was bad because IE doesn't allow áéíóú letters (commonly used in spanish) instead displaying a square character therfor it could't process the XML.