function syncText() {
var xhr = new XMLHttpRequest();
xhr.open("get", "data/contacts.txt", false);
xhr.send(null);
if (xhr.status == 200) {
var data = xhr.responseText;
var items = data.split("|");
items.sort();
var div = document.getElementById("header2");
for (var i = 0; i < items.length; i++) {
var p = document.createElement("p");
var text = document.createTextNode(items[i]);
p.appendChild(text);
div.appendChild(p);
}
} else {
alert("data retrieval failed...");
}
}
i want to extract the value of kate, jessica, johnny and place it in a div
02-09-2013, 10:15 AM
JMRKER
Your ajax call will work best when then .txt file is on the server.
I believe only IE can read the file locally, and that might be using some special code to replace the ajax call.
Modify my last post to pull in the .txt file using ajax logic from the server.