I am new to XML and web development in total, so please bare with me - I am learning, so this may be super easy, but I have spent hours struggling with this.
Background on what I am building: I am creating a form which links to an XML file. On the form there are checkboxes, I want to pull the 'text' for the checkbox from the xml file.
The code I have for the checkboxes is:
$('.cb').on('click', function () {
nextID = $(this).attr('target');
nextEl = $('#' + nextID);
if (!nextEl.is('visible')) {
nextEl.show();
}
});
and the code I have been playing with:
var XML_PATH = "xml/test.xml";
$(function(){
$.ajax({
type: "GET",
url: "XML_PATH",
dataType: "xml",
success: function(xml){
$(xml).find('cb').each(function(i){
var ou = $(this).text();
$('#cb').append("<input class='cb' value='"+ id +"'>"+ root +">");
});
}
});
});
I have fiddled with various bits of code to try and link the xml file, with no joy. Just hoping for some guidance and advice on how to go about this. I could be looking at the completely wrong thing. I've also been unable to find an example I can use for guidance.
Thank you very much for any guidance/advice given.
Aucun commentaire:
Enregistrer un commentaire