简体   繁体   中英

Reload a div element using jquery

I have a data table in my spring mvc project. I need to refresh this table after editing or deleting the data without refreshing the whole page. Here is html div element.

<div id="datatable"> </div>

I tried it in this way. $("#datatable").load("butterflyImage #datatable"); ButterflyImage is the name of the jsp page. But it didn't work. What is the issue?

When I try $("#datatable").load("butterflyImage'); The whole page will appear on within datatable div element.

You could do it this way:

$.get("butterflyImage",function(response){
    $("#datatable").html($(response).find("#datatable").html());
});

But it's very inefficient and would be better to have the jsp just output the content that you need to refresh.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM