Model view controller 敲除js中mvcwebapi中的post方法
我需要的样本和例子后,删除,把MVCWebAPI与淘汰js方法。在MVCWebAPI中运行Post方法时出错 这里是我的Post方法代码:Model view controller 敲除js中mvcwebapi中的post方法,model-view-controller,knockout.js,Model View Controller,Knockout.js,我需要的样本和例子后,删除,把MVCWebAPI与淘汰js方法。在MVCWebAPI中运行Post方法时出错 这里是我的Post方法代码: $.ajax({ url: 'api/product/PostProduct/', cache: false, type: 'POST', contentType: 'application/json; charset=utf-8', data: ko.toJSON(Product), success: function
$.ajax({
url: 'api/product/PostProduct/',
cache: false,
type: 'POST',
contentType: 'application/json; charset=utf-8',
data: ko.toJSON(Product),
success: function (data) {
alert('added');
self.Products.push(data);
self.BrandName("");
self.price("");
self.GenericName("");
}
}).fail(
function (xhr, textStatus, err) {
alert('error');
});
您的POST-URL与REST不同。您确定有“POSTProduct”后缀服务器端吗?出现了什么错误?它不会发布到服务器中。它以错误的形式返回数据。