[英]Redirect back to Default.aspx
I have a default.aspx (c#) page which has a simple Post AJAX call to a WebMethod
that returns a JSON object, so that I can then populate a DataTable. 我有一个default.aspx(c#)页面,该页面具有对
WebMethod
的简单Post AJAX调用,该WebMethod
返回JSON对象,以便随后可以填充DataTable。 All worked fine until I introduced a login page. 在引入登录页面之前,一切工作正常。 Now, when a user is redirected to the Default page, after logging in, the Post never appears in FireBug.
现在,将用户重定向到“默认”页面后,登录后,“帖子”将永远不会出现在FireBug中。
This is my AJAX call: 这是我的AJAX呼叫:
$.ajax({
type: 'POST',
url: '/Default.aspx/GetValueDateSummary',
contentType: 'json',
data: {},
sucess: function (response) {
renderTable(response.d);
},
error: function (errMsg) {
$('#errorMessage').text(errMsg);
}
});
});
with the code behind being: 后面的代码是:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
public static List<ValueDateSummary> GetValueDateSummary()
{
some code in here.....
return drList;
}
sucess: function (response) {
应该
success: function (response) {
Are you using a ScriptManager object? 您是否正在使用ScriptManager对象? If so, I believe that you need to enable page methods for it to work.
如果是这样,我认为您需要启用页面方法才能使其工作。
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
Ok, i sorted it. 好吧,我整理了一下。
here is the complate Ajax call, seems i was missing the proper contentType and dataType 这是compate Ajax调用,似乎我缺少适当的contentType和dataType
$.ajax({
type: 'POST',
url: 'Default.aspx/GetValueDateSummary',
contentType: 'application/json;charset=utf-8',
dataType: 'json',
success: function (response) {
console.log(response);
alert(response.d);
renderTable(response.d);
},
error: function (errMsg) {
$('#errorMessage').text(errMsg);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.