且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Ajax - 无法加载资源:服务器响应状态为500(内部服务器错误)

更新时间:2022-02-19 23:40:47

.ajax({
url:' / api / CustomersInfo / Post'
类型:' post'
data:dataObject ,
contentType:' application / json'
成功: function (data){
addCustomerViewModel.customerListViewModel.customers.push( new Customer(data.Id,data) .CustomerName,data.ContactName,data.Address,data.City,data.PostalCode,data.Country));
self.Id( null );
self.CustomerName(' ' 跨度>);
self.ContactName(' ');
self.Address(' ');
self.City(' ');
self.PostalCode( 0 );
self.Country(' ');
}
});
};
}

// 用作客户列表视图的视图模型
function CustomersList(){

var self = 此跨度>;

// 可观察数组是数组更改时的更新绑定元素
self.customers = ko.observableArray([]);

self.getCustomers = function (){
// 从服务器端检索客户列表并将每个对象推送到模型的学生列表
self.customers.removeAll();
.ajax({ url: '/api/CustomersInfo/Post', type: 'post', data: dataObject, contentType: 'application/json', success: function (data) { addCustomerViewModel.customerListViewModel.customers.push(new Customer(data.Id,data.CustomerName, data.ContactName, data.Address, data.City, data.PostalCode, data.Country)); self.Id(null); self.CustomerName(''); self.ContactName(''); self.Address(''); self.City(''); self.PostalCode(0); self.Country(''); } }); }; } // use as customer list view's view model function CustomersList() { var self = this; // observable arrays are update binding elements upon array changes self.customers = ko.observableArray([]); self.getCustomers = function () { // retrieve customers list from server side and push each object to model's students list self.customers.removeAll();


.getJSON(' / api / CustomersInfo / Get' function (data){
.getJSON('/api/CustomersInfo/Get', function (data) {


.each(data, function (key,value){
self.customers.push( new Customer(value.Id,value.CustomerName,value.ContactName,value.Address,value.City,value.PostalCode,value。国家));
});
});
};


// 删除客户。当前数据上下文对象自动传递给函数。
// self.removeCustomer = function(客户){
//
.each(data, function (key, value) { self.customers.push(new Customer(value.Id,value.CustomerName, value.ContactName, value.Address, value.City, value.PostalCode, value.Country)); }); }); }; // remove customer. current data context object is passed to function automatically. //self.removeCustomer = function (customer) { //