这是整个交易和控制的希望,这将提供更多解决方案
IHttpActionResult在更新数据时生成xml解析器错误
[ResponseType(typeof(void))]
public IHttpActionResult Postzl_volunteer(int id, zl_volunteer zl_volunteer)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
if (id != zl_volunteer.id_volunteer)
{
return BadRequest();
}
db.Entry(zl_volunteer).State = EntityState.Modified;
try
{
db.SaveChanges();
}
catch (DbUpdateConcurrencyException)
{
if (!zl_volunteerExists(id))
{
return NotFound();
}
else
{
throw;
}
}
所有api工作正常,未更新表行(api)。错误:XML解析器错误
<script type="text/javascript">
$('#updatecustomer').click(function (data) {
var idcustomer = $('#editid').val();
var firstnamen = $("#firstname").val();
var midnamen = $("#midname").val();
var lastnamen = $("#lastname").val();
var fullnamen = $("#fullname").val();
var custphone = $("#customphone").val();
var volmail = $("#volmail").val();
var postcodes = $("#custompostal").val();
var streetnr = $("#customhnum").val();
var customstreets = $("#customstreet").val();
var customplace = $("#tcplace").val();
var datatest = $("#test").val();
$.ajax({
url: '/api/zl_volunteer/34',
cache: true,
dataType: 'json',
type: "post",
data: {
firstname: firstnamen, midname: midnamen, lastname: lastnamen,
full_name: fullnamen, postcode: postcodes, email: volmail, phone_mob: custphone,
adr_number: streetnr, adress: customstreets, place: customplace, gender: datatest, age: datatest, phone: datatest, comment: datatest
},
success: function (data) {
$(data).each(function (i, item) {
$(item).each(function (i, nwid) {
console.log('Nieuw ID ' + nwid.full_name);
$("#editscid").val(nwid.id_training);
});
});
},
error: function (request, status, error) {
console.log('error', error)
},
complete: function () {
console.log('Succesvol Opgeslagen');
$("#saving").css("display", "none");
$("#editmode").val(1);
setTimeout(function () {
}, 3000);
}
});
});
</script>
输出在控制台中给出: XML解析错误:找不到主要元素位置:http://localhost:63084/api/zl_volunteer/34 行号1,行1: