成功调用函数后,使用 Ajax 调用刷新 Telerik MVC 网格?
我看到这个网站上有很多相关的问题。但我仍然无法满足我的要求。
这是我的 ajax 调用
$.ajax({
type: "POST",
url: "/Medication/StopMedication",
data: { ID: pid, StopNote: note },
dataType: "json",
success: function () {
refreshGrid()
}
});
,我的刷新网格是这样的
function refreshGrid() {
alert("I am at Refresh Grid");
if ($(".t-grid .t-refresh").exists()) {
$(".t-grid .t-refresh").trigger('click');
}
}
首先,成功后我的 ajax 调用不会触发刷新网格()函数。 任何人都可以帮我解决这个问题,
我发现了问题并解决了它:
I Made these Changes
dataType: "text",
success: function (data) {
refreshGrid();
}
function refreshGrid() {
$(".t-grid .t-refresh").trigger('click');
}
I see there are lot of related question in this site. But Still I am not able to make this work for my requirement.
This is my ajax call
$.ajax({
type: "POST",
url: "/Medication/StopMedication",
data: { ID: pid, StopNote: note },
dataType: "json",
success: function () {
refreshGrid()
}
});
and my refresh grid is like this
function refreshGrid() {
alert("I am at Refresh Grid");
if ($(".t-grid .t-refresh").exists()) {
$(".t-grid .t-refresh").trigger('click');
}
}
First of all after success my ajax call is not firing refreshGrid() function.
can any one help me with this
I found the issue and fixed it:
I Made these Changes
dataType: "text",
success: function (data) {
refreshGrid();
}
function refreshGrid() {
$(".t-grid .t-refresh").trigger('click');
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
要重新加载网格,请在成功 ajax 调用后使用它
享受
to reload the grid use this after success ajax call
enjoy
首先需要排查为什么没有调用成功回调。也许有一个错误。您可以尝试处理 $.ajax 的
error
看看是什么回应是。您还可以使用一些 HTTP 嗅探工具(WebKit 的开发人员工具,FireBug 或 Fiddler)来检查服务器响应是什么。当您整理出未调用的成功处理程序时,您可以使用 ajaxRequest 网格方法来刷新它。
You need to troubleshoot first why the success callback is not invoked. Perhaps there is an error. You can try handling the
error
of $.ajax to see what the response is. You can also use some HTTP sniffing tool (WebKit's developer tools, FireBug or Fiddler) to inspect what the server response is.When you sort out the success handler not being invoked you can use the ajaxRequest method of the grid to refresh it.
这有效或我
This worked or me
通过这种方式
,如果您有多个网格,它将刷新页面上的所有网格。甚至细节网格也会被刷新。
为了防止这种情况,您可以使用网格的 ID
In this way
it would refresh all of your grids on your page, if you have more than one grid. Even the detail grids will be refreshed.
To prevent this you can use the Id of your grid
对于服务器绑定 Telerik Grid 只需要做以下事情......只需使用并欢呼
在任何事件之后您都可以调用此
For Server Bindings Telerik Grid Just need to do the following Thing..... Just use and cheers
After any event you can call this