JavaScript & XML
Помогите!!! не загружает базу!!
*************XML*************
var g_url = "http://twost.ru/basic.xml";
***************script*********
function load_dictionary()
{
try
{
g_request = new XMLHttpRequest();
g_request.onreadystatechange = events_callback();
g_request.open("GET", g_url, false);
g_request.send();
}
catch(error)
{
number.innerText = "No base";
}
}
function events_callback()
{
if (g_request.readyState == 4 && g_request.status != 404)
{
g_words = new Array();
g_index = new Array();
var xml = g_request.responseXML;
var nodes = xml.selectNodes("/dictionary/word");
g_count = nodes.length;
for (var i = 0; i < nodes.length; i++)
{
g_words[i] = new Object();
g_words[i][g_src] = nodes.item(i).selectSingleNode(g_src).text;
g_words[i][g_dst] = nodes.item(i).selectSingleNode(g_dst).text;
var pos = nodes.item(i).attributes.getNamedItem(g_pos).text;
g_words[i][g_pos] = pos;
if (g_index[pos] == null)
g_index[pos] = new Array();
g_index[pos].push(i);
}
g_loaded = (g_words.length > 0);
}
}
|