Update XML node through Javascript/JQuery/AJAX -


i have been searching day, , have found promising options, haven't panned out me (ie. is possible add,delete xml nodes jquery $.ajax?). believe biggest issue not being overly familiar ajax or xml, here problem simplified: need update local xml page through html page (without use of php or other server-side tools). working within vendor-provided solution (so cannot modify product much).

here's snippets of have working: mobilesettings.xml:

<settings>  <application>    <firstcase>publicmonitor</firstcase>  </application> </settings> 

customsettings.js:

function loadsettings() {     $.ajax({         type: "get",         url: '../configurations/mobilesettings.xml',         datatype: "xml",         success: function(xml) {             $(xml).find('firstcase').each(function () {                 startpage.value = $(this).text();             });         }     }); } 

what cannot work part of same .js, save. can see commented code number of failed attempts. (between load , save, user can change simple dropdown box select new value.):

function savesettings() {     startp = startpage.value;     $.ajax({         type: "put",         url: '../configurations/mobilesettings.xml',         datatype: "xml",         success: function(xml) {             $(xml).find('firstcase').each(function () { //               $(this).text(startp);                $(this).attr(startp); //             $(this).find('firstcase').text("test"); //              $(this).setattribute("firstcase", "test"); //                var elem = document.createelement('firstcase'); //                xml.find('application').append(elem); // appends <app></app> <layout> //                $(this).find('firstcase').text() = startpage.value;             });         }     }); } 

my assumption there nothing here sending data xml. have been searching tirelessly, have not found solution works. again, cannot use server-side scripting, solution must ajax/jquery/javascript ... not know work.

thanks in advance.

edit 07.02.2015

i believe may not have been clear should have been. problem lies in changing .xml file through ajax, etc. know how manipulate data on user page, need user able declare new value need saved existing .xml page. user has dropdown menu provide them valid values , upon submit, xml file needs change firstcase node else:

<settings>  <application>    <firstcase>privatemonitor</firstcase>  </application> </settings> 

the fiddle provided in comments (http://jsfiddle.net/py5dvk6e/) works create xml string, not know how save string .xml file called in customsettings.js file (above).


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -