Update my content into XML-file



I just gratefully managed to load the content of an XML-file into my php-document, like so:



$(document).ready(function () {
$.ajax({
type: "GET",
url: "abstimmer.xml",
dataType: "xml",
success: function (xml) {
var $lis = $(".abstimmer li");
$(xml).find('klick').each(function (index) {
if (index < $lis.length) {
$lis.eq(index).html($(this).text());
}
});
}
})
})


By that, the content of these nodes get pushed into the li-elements of the parental ul-element identifiable with class "abstimmer".


I now want to also push data from the php-file back into the xml-file. I'd like to do this by counting the clicks on a li-element, what I do in that manner:



$(".abstimmer li").click(function(){
this.clicked=this.clicked?this.clicked+1:1;
$(this).html(this.clicked)
var klick_neu = $(this).html(this.clicked);
// Where would I need to go from here?
});


I know, that I now need to send var klick_neu to a php-file that somehow parses the var klick_neu and pushes it into that xml-file. But I have no clue how to do that. Could somebody help me with that?


And I am not sure, if that's alright with stackoverflows' rules, but I am just curious on an additional thing within the same problem: If I just added an onClick-Event within the ready-function, I could "seamlessly" load the updated content of the xml-file into my list - right?


Thanks a lot.


No comments:

Post a Comment