jQuery 如何仅重新加载jquery中的元素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18973606/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 22:52:49  来源:igfitidea点击:

How to reload only element in jquery

javascriptjquery

提问by MintY

I am trying to reload only a particular element using jquery

我正在尝试使用 jquery 仅重新加载特定元素

I have a table, that table has submit button at the last column, whenever I click the refresh button it has to reload only 2 column of a that row.

我有一个表,该表在最后一列有提交按钮,每当我单击刷新按钮时,它只需要重新加载该行的 2 列。

How can I do this?

我怎样才能做到这一点?

here is code I have used:

这是我使用过的代码:

$("button").click(function(){
  $(this).parent().siblings(".b1").reload();
  $(this).parent().siblings(".b2").reload();
});

But this is not reloading the element of table row.

但这不是重新加载表格行的元素。

How can I solve this?

我该如何解决这个问题?

回答by jfriend00

A jQuery object does not have a .reload()method so you can't reload data with the code you're using.

jQuery 对象没有.reload()方法,因此您无法使用正在使用的代码重新加载数据。

If the data in the table was loaded dynamically via an ajax call, then you will need to make your own ajax call to retrieve new, updated data and insert it into the table.

如果表中的数据是通过 ajax 调用动态加载的,那么您将需要进行自己的 ajax 调用来检索新的、更新的数据并将其插入到表中。

If the data was loaded with .load()(which uses an ajax call under the covers), then you can call .load()again with the same arguments you used the first time. There is no .reload().

如果数据已加载.load()(在幕后使用 ajax 调用),那么您可以.load()使用第一次使用的相同参数再次调用。没有.reload()

回答by Ken Herbert

Because .reload()is not a valid jQuery function.

因为.reload()不是有效的 jQuery 函数。

Just keep doing it the way you were shown in the other question.

继续按照您在另一个问题中显示的方式进行操作。