我想用jQuery和xml作为我的数据库建立客户端。
我找到了这个:$.twFile
我不知道为什么我的代码不起作用,因为我可以加载xml但是我不能在我的xml中添加一些东西?
有人可以帮助我如何使用xml作为数据库从jQuery向客户端添加内容吗?
加载方法有效:
var contacten = new Array();
var xmldoc=null;
//xml
$.ajax({
type: "GET",
url: "Data.xml",
dataType: "xml",
success: readXml
});
function readXml(xml) {
xmldoc=$(xml);
$(xml).find("Contacten").each(function () {
$(this).find("Contact").each(function () {
var Id = $(this).find("Id").text();
var Naam = $(this).find("Naam").text();
var Functie = $(this).find("Functie").text();
var Bedrijf = $(this).find("Bedrijf").text();
var Foto = $(this).find("Foto").text();
var Beschrijving = $(this).find("Beschrijving").text();
var Adres = $(this).find("Adres").text();
var Tel = $(this).find("Tel").text();
var Email = $(this).find("Email").text();
var Level = $(this).find("Level").text();
var Group = $(this).find("Group").text();
var Team = $(this).find("Team").text();
contact = new Array(Naam, Functie, Bedrijf, Foto, Beschrijving, Adres, Tel, Email, Level, Group, Team);
contacten.push(contact);
});
});
createGui();
};
function createGui() {
$.each(contacten, function (contactId, gegevens) {
$('#contactlijst').append("<li id='" + contactId + "'><img src='img/pics/" + gegevens[3] + "'/><h2>" + gegevens[0] + "</h2><h3>" + gegevens[1] + " at " + gegevens[2] + "</h3></li>");
});
}
问题是当我需要向xml添加内容时:
$.twFile.save("D:\foo.txt", "test")
答案 0 :(得分:0)
你必须回复服务器。你试过$ .post吗?
$.post(
function(result){
alert(z)
}
)
希望这会有所帮助