如何将javascript对象传递回服务器
我正在使用wenzhixin引导表(因为我被要求使用它) 我有一堆搜索字段,所以在帖子中,我把所有字段都打包好,整齐地发送回服务器。 但正如您所看到的,pageParam中的所有字段都为null,但PrefixNameID应为1。请注意,pageNumber、pageSize和sortOrder都是正确的且不为空 有没有什么明显的迹象表明我做错了 编辑:Ajax调用-这是作者的代码如何将javascript对象传递回服务器,javascript,c#,asp.net-mvc,bootstrap-table,Javascript,C#,Asp.net Mvc,Bootstrap Table,我正在使用wenzhixin引导表(因为我被要求使用它) 我有一堆搜索字段,所以在帖子中,我把所有字段都打包好,整齐地发送回服务器。 但正如您所看到的,pageParam中的所有字段都为null,但PrefixNameID应为1。请注意,pageNumber、pageSize和sortOrder都是正确的且不为空 有没有什么明显的迹象表明我做错了 编辑:Ajax调用-这是作者的代码 request = $.extend({}, calculateObjectValue(null, this
request = $.extend({}, calculateObjectValue(null, this.options.ajaxOptions), {
type: this.options.method,
url: this.options.url,
data: this.options.contentType === 'application/json' && this.options.method === 'post' ?
JSON.stringify(data) : data,
cache: this.options.cache,
contentType: this.options.contentType,
dataType: this.options.dataType,
success: function (res) {
res = calculateObjectValue(that.options, that.options.responseHandler, [res], res);
that.load(res);
that.trigger('load-success', res);
},
error: function (res) {
that.trigger('load-error', res.status);
},
complete: function () {
if (!silent) {
that.$loading.hide();
}
}
});
编辑2:
JSON.stringify(data): "{"pageSize":10,"pageNumber":1,"sortOrder":"asc","pageParam":{"ID":null,"PrefixNameID":null,"FirstName":null,"MiddleName":null,"LastName":null,"SuffixName":null,"Address1":null,"Address2":null,"City":null,"StateID":null,"Zipcode":null,"EmployeeTypeID":null,"NPI":null}}"
天哪,它是空的 ajax调用是什么样子的?那么,有机会看到ajax吗?你能发布JSON.stringify(数据)的结果吗?用JSON.stringify(数据)更新我不理解你的问题。当然,从您发布的内容来看,它将是空的,因为您根据您的第一个图像
p.pageParam={一个所有字段都为空的json定义}
,将它分配给空。您实际在哪里分配p.pageParam.FirstName=“Harry”
等?如果希望自动填充这些字段,请使用Ajax.BeginForm
工作流或knockout.js
等。