I'm trying to update a XML file via jquery Ajax at client and php simple_XML at server.
My ajax code is:
$("input[type='radio']").click(function () {
$().progress();
$.ajax({
type: "POST",
url: "save.php",
data: {name: $(this).attr('name'), value: $(this).val(), id: 13618},
});
});
in save.php
i've:
$path="";
$xmlfile=$path.'vote/'.$_POST['id'].'.xml';
$xml = simplexml_load_file($xmlfile);
$xml->'a'.$_POST['name']=$_POST['value'];
$xml->asXML($path.'vote/'.$_POST['id'].'.xml');
return;
vote/13618.xml
contains a template of XML tags each starting with an extra 'a'.
e.g.: for this fiddle, in my xml file, i've:
<posts>
<a1president/>
<a2vice-president/>
</posts>
but the php file is not updating the xml file. i'm unable to track the bug.
is there any error in my code? if yes where and how to fix?