首页 新闻 会员 周边 捐助

mvc 使用jQuery实现查询问题

0
悬赏园豆:30 [已解决问题] 解决于 2010-09-01 17:05

在页面中使用AjaxPager实现页面绑定,用$.ajax做参数传递时,如果返回的参数页数大于1,就会出现问题,提示AjaxPager有个key的值为null。但是换成$.post传递参数时,就不会出现类似问题,那位大侠帮忙看下为什么。

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<PagedList<ResouceManage.Models.Stat.ResourceUseForm>>" %>
<%@ Import Namespace="Webdiyer.WebControls.Mvc" %>
<div id="dvListRs">
<script type="text/javascript">
var pageindex_p74
=<%= ViewData["pageindexRs"]==null?"0":ViewData["pageindexRs"].ToString()%>;
</script>
<div style="clear: both">
</div>
<div>
<%=Html.AjaxPager(Model, new PagerOptions
{
ContainerTagName
= "span",
FirstPageText
= "首页",
LastPageText
= "尾页",
PrevPageText
= "上一页",
NextPageText
= "下一页",
PageIndexParameterName
= "id",
AlwaysShowFirstLastPageNumber
= true,
HorizontalAlign
= "right",
NumericPagerItemWrapperFormatString
= "<span class=\"cpb\">{0}</span>",
NavigationPagerItemWrapperFormatString
= "<span class=\"ppb\">{0}</span>"
},
new AjaxOptions() { UpdateTargetId = "dvList",OnBegin = "AjaxGetDataStart", OnComplete = "AjaxStop" }, new { Style = "float:right;width:40%;" })%>
</div>

 

 

function SearchClick() {
var date
= new Date();
var project
= $.trim($("#DDLProject").val());
var resourcetype
= $.trim($("#DDLResourceType").val());
var businesstype
= $.trim($("#DDLBusinessType").val());
var resourcestatus
= $.trim($("#DDLResourceStatus").val());
var OpenstartDate
= $.trim($("#OpenstartDate").val());
var OpenendDate
= $.trim($("#OpenendDate").val());
var ClosestartDate
= $.trim($("#ClosestartDate").val());
var CloseendDate
= $.trim($("#CloseendDate").val());
$.ajax({
type:
"get",
url:
"/Stat/QueryUseResource?" + "project=" + project + "&resourcetype=" + resourcetype + "&businesstype=" + businesstype + "&resourcestatus=" + resourcestatus + "&OpenstartDate=" + OpenstartDate + "&OpenendDate=" + OpenendDate + "&ClosestartDate" + ClosestartDate + "&CloseendDate" + CloseendDate + "&random=" + date.getTime().toString(),
beforeSend: function (XMLHttpRequest) {
// AjaxGetDataStart();
},
success: function (data, textStatus) {
$(
"#dvListRs").html(data);
},
complete: function (XMLHttpRequest, textStatus) {
// AjaxStop();
},
error: function () {
//请求出错处理
// alert("111");
}
});
// AjaxGetDataStart();
// $.post("/Stat/QueryUseResource",
// {
// project: $.trim($("#DDLProject").val()),
// resourcetype: $.trim($("#DDLResourceType").val()),
// businesstype: $.trim($("#DDLBusinessType").val()),
// resourcestatus: $.trim($("#DDLResourceStatus").val()),
// OpenstartDate: $.trim($("#OpenstartDate").val()),
// OpenendDate: $.trim($("#OpenendDate").val()),
// ClosestartDate: $.trim($("#ClosestartDate").val()),
// CloseendDate: $.trim($("#CloseendDate").val())
// },
// function (returnText) {
// $("#dvListRs").html(returnText);
// AjaxStop();
// });

}

 

菜鸟老了的主页 菜鸟老了 | 初学一级 | 园豆:145
提问于:2010-08-17 21:04
< >
分享
最佳答案
0

jquery中$.post实际上还是调用$.ajax,只不过是POST获取数据,会出现这种问题应该还是$.ajax调用时的type: "get"的问题,$.ajax的type改成"POST"看看,估计是你的MVC控制器返回数据的方法指定了POST获取数据。

收获园豆:30
kyo-yo | 大侠五级 |园豆:5587 | 2010-08-18 09:47
和type"get"无关, 因为其他页面也有类似代码 也是用$.ajax type:"get“ 但是不会出错
菜鸟老了 | 园豆:145 (初学一级) | 2010-08-18 10:43
@菜鸟老了:而且如果返回的页数不需要绑定翻页,就不会出粗
菜鸟老了 | 园豆:145 (初学一级) | 2010-08-18 10:43
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册