我有以下xml文件:
<User>
<Address>123</Address>
<FirstName>John</FirstName>
<SecondName>Smith</FirstName>
</User>
我正在尝试通过AJAX调用来更改它:
var addressid= = 123;
$.ajax({
type: "GET",
url: url,
headers: {
"Authorization": "Basic " + btoa("username:password"),
},
contentType: "application/xml",
dataType: "xml",
async: true,
crossDomain: true,
success: function(xmlResponse) {
alert("Your user has been edited");
$(xmlResponse).find('User').each(function(){
if($(this).find('Address').text() == addressid) {
$(this).find('FirstName').text("Jenifer");
$(this).find('SecondName').text(secondName);
}
});
}
});
警报来了,它不会显示任何错误,但是不会传递给系统。这意味着,如果我从服务器获取数据,则会显示旧名称。我在做什么错了?