[英]Jtable An error occured while communicating to the server. - post 500 error
when i am adding a new record i have the above error below is my code, i am stuck done some search on google but i am going nowhere i would be greateful if someone can point me in the right direction. 当我添加新记录时,上面的错误是我的代码,我被困在Google上进行了一些搜索,但是我走不通,如果有人可以指出正确的方向,我将非常感激。
$('#dataContent').jtable({
title: 'Data List',
paging: true,
pageSize: 5,
actions: {
listAction:'/Test.aspx/GetAllCars',
createAction: 'Test.aspx/CreateCar'
},
fields: {
ID: {
key: true,
create: false,
edit: false,
list: false
},
Make: {
title: 'Make',
width: '20%'
},
Model: {
title: 'Model',
width: '20%'
},
Engine: {
title: 'Engine',
width: '20%'
},
Year: {
title: 'Year',
width: '20%'
}
}
});
$('#dataContent').jtable('load');
});
[WebMethod(EnableSession = true)]
public static Object CreateCar(Car c) {
try {
bool addresult = new CarRepo().CreateCar(c);
return new { Result = "OK" };
}
catch (Exception ex) {
return new { Result = "ERROR", Message = ex.Message };
}
}
public bool CreateCar(Car c) {
using(var context = new DAL.DbAccess.DataContext()) {
try {
var Irepo = new DAL.Repository.MainRepository<Car>(context);
Irepo.Insert(c);
return true;
} catch(Exception ex) {
ex.ToString();
return false;
}
}
}
POST http://localhost:51598/Test.aspx/GetAllCars POST http:// localhost:51598 / Test.aspx / GetAllCars
200 OK 4ms jquery-....min.js (line 3) POST http://localhost:51598/Test.aspx/CreateCar 200 OK 4ms jquery -.... min.js(第3行)POST http:// localhost:51598 / Test.aspx / CreateCar
500 Internal Server Error 7ms jquery-....min.js (line 3) HeadersPostResponseJSON 500 Internal Server Error 7ms jquery -.... min.js(第3行)HeadersPostResponseJSON
{"Message":"Invalid web service call, missing value for parameter: \'c\'.","StackTrace":" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary 2 parameters)\\r\\n at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary
2 parameters)\\r\\n at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\\r\\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"} {“ Message”:“无效的Web服务调用,缺少参数值:\\ u0027c \\ u0027。”,“ StackTrace”:“位于System.Web.Script.Services.WebServiceMethodData.CallMethod(对象目标,IDictionary
2 parameters)\\r\\n at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary
2参数)\\ r \\ n在System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext上下文,WebServiceMethodData methodData,IDictionary`2 rawParams) \\ r \\ n,位于System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext上下文,WebServiceMethodData methodData)“,” ExceptionType“:” System.InvalidOperationException“}
500 is a server unexpected condition code. 500是服务器意外条件代码。 This doesn't look like a JavaScript issue.
这看起来像不是JavaScript问题。 You are using a .Net aspx page.
您正在使用.Net aspx页面。 You may want to be sure the IIS server is setup and functioning correctly.
您可能要确保IIS服务器已安装且正常运行。
http://www.w3.org/Protocols/HTTP/HTRESP.html http://www.w3.org/Protocols/HTTP/HTRESP.html
find the problem it should be 找到应该的问题
[WebMethod(EnableSession = true)]
public static Object CreateCar(Car **record**) {
try {
bool addresult = new CarRepo().CreateCar(record);
return new { Result = "OK" };
}
catch (Exception ex) {
return new { Result = "ERROR", Message = ex.Message };
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.