jQuery在Ajax发布之后无法正常工作(jQuery not working after Ajax post)

编程入门 行业动态 更新时间:2024-10-20 06:24:24
jQuery在Ajax发布之后无法正常工作(jQuery not working after Ajax post)

我目前正在使用MVC页面,我正在使用Grid.Mvc表。 我也有一些搜索字段,我可以通过Ajax Post更新表,一旦我使用搜索字段并提交排序html被替换后回复,一旦被替换,网格行不能像Ajax调用之前一样点击,就像ajax调用是杀死javascript或Jquery或两者,

这是网格的Ajax调用的代码:

$(function() { $(document) on.("click", "#buscar", function() { $.ajax({ url: '/MainPage/Grid', type: 'POST', async: false, datatType: 'html', processData: true, data: { url: $('#url').val(), isInternal: ('#isInternal').val() }, success: function(data) { $('#grid').html(data); } }) }); });

这是我单击我发送另一个Ajax调用的行时的代码,但在第一个代码发布后,网格变得无法点击;

$(function() { pagesGrids.linksgrid.onRowSelect(function() { $.ajax({ url: '/mainpage/getlinkdetails', type: 'POST', async: false, dataType: 'html', processData: true, data: { id: e.row.BrokenId }, success: function(data) { $('#linkdetails').html(data); }, error: function() { alert('something went wrong') } }) }); })

任何帮助或暗示可以指出我正确的方向将非常感谢,谢谢

UPDATE

它自己的网格是在MVC上的Index处呈现的局部视图

<div id="grid">
  @Html.Action"Grid"
</div>

I'm currently working with an MVC page where I'm using Grid.Mvc table. I also have some search fields where I can update the table via Ajax Post, once I use the search fields and submit for sorting the html gets replaced on post-back, once replaced, the grid rows can NOT be clicked like before the Ajax call, is like the ajax call is killing the javascript or Jquery or both,

here is code for the Ajax call for the grid:

$(function() { $(document) on.("click", "#buscar", function() { $.ajax({ url: '/MainPage/Grid', type: 'POST', async: false, datatType: 'html', processData: true, data: { url: $('#url').val(), isInternal: ('#isInternal').val() }, success: function(data) { $('#grid').html(data); } }) }); });

Here is the code for when I click the rows I send another Ajax call, but after the first code post the grid becomes unclickable;

$(function() { pagesGrids.linksgrid.onRowSelect(function() { $.ajax({ url: '/mainpage/getlinkdetails', type: 'POST', async: false, dataType: 'html', processData: true, data: { id: e.row.BrokenId }, success: function(data) { $('#linkdetails').html(data); }, error: function() { alert('something went wrong') } }) }); })

Any help or hint that can point me in the right direction will greatly appreciated, thanks

UPDATE

The the grid it self is a partial view rendering at Index on MVC

<div id="grid">
  @Html.Action"Grid"
</div>

                

最满意答案

您的局部视图将新元素呈现到页面中,而不是更改现有元素。

在部分回发后,您需要将javascript事件(单击)重新绑定到新元素。

Your partial view is rendering new elements into the page rather than altering the existing elements.

You will need to rebind the javascript events (click) to the new elements after the partial postback.

更多推荐

Ajax,function,grid,data,电脑培训,计算机培训,IT培训"/> <meta name="descr

本文发布于:2023-08-05 08:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1428838.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法正常   工作   Ajax   jQuery   working

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!