jquery ajax not working with php simple_xml -
this question has answer here:
- how useful error messages in php? 27 answers
i'm trying update xml file via jquery ajax @ client , php simple_xml @ 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 template of xml tags each starting 'a'.
e.g.: this fiddle, in xml file, i've:
<posts> <a1president/> <a2vice-president/> </posts>
but php file not updating xml file. i'm unable track bug.
is there error in code? if yes , how fix?
you firing asxml, don't return value. if do, can check if function returns false
or true
.
if returns false, check further response. make sure you've enabled error reporting:
error_reporting(-1);
Comments
Post a Comment