I'm trying to modify an existing xml document that i stored from an earlier ajax call into a global variable named "XML".
Now, im trying to change a title in the xml document to be whatever the user wants to change it to. For some reason i keep getting "uncaught type error: Illegal invocation" after my ajax put call, however my success function executes. My code is below:
$("#saveButton").click(function(event) {
var url = links[$("#nameInput").val()]; //the url of the xml file to be modified
changeXML(XML); //XML is global variable where i stored the xml file from 'GET' call earlier
$.ajax({
url: url,
data: XML,
type: 'PUT',
dataType: 'xml',
success: window.location.reload()
});
});
function changeXML(xml){
var title = $("#titleInput").val();//obtains user input for title change
$(xml).find('title').first().text(title);//changes title to what user entered
}
The global variable xml file that i saved is actually being modified, however upon reloading the window, i find that the xml file that the changes are supposed to be put into isnt changing, just the local variable one. What am I doing wrong?
No comments:
Post a Comment