具体报错信息如下
HTTP Status 415 -
type Status report
message
description The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
我提交的表单内容转成了json,因为不想再做数据转换的代码,我用的是easyui。把更新过的列都读取出来,代码如下所示
var rows = $('#dg').datagrid('getChanges',2);
ajax提交的代码如下所示
$.ajax({ type: "post", url: '', data: $.toJSON(rows), dataType: "json", async: false, success: function (data, status) { } },2);
提交ajax就报HTTP Status 415错误了。解决该问题的方法很简单,就是加上代码:contentType: "application/json",具体代码如下
$.ajax({ type: "post", url: '', data: $.toJSON(rows), dataType: "json", contentType: "application/json", async: false, success: function (data, status) { } },2);
这样就解决415错误提示了。