Shawn Vn
Shawn Vn

Reputation: 297

Can I reload a page that loaded with .load?

I'm adding new data to database but to load the new data I have to reload the page I was wondering is there anyway to reload a loaded page without refreshing the whole page ?
P.S : I have used the .html thing and it won't load new data

$(document).ready(function () {
$(".container").load("../../public/include/menu/add.php");
    $("#add_from").ajaxForm(function () {
            $(".container").reload("../../public/include/menu/add.php");
    });

Upvotes: 0

Views: 38

Answers (2)

Cradoe
Cradoe

Reputation: 136

If your default data is being fetched with ajax, you probably just need to call the fetch method. You can use location.reload() instead, if you aren't fetching with ajax.

Upvotes: -1

David
David

Reputation: 218960

You may be overthinking this. Consider how you load your data from the server:

$(".container").load("../../public/include/menu/add.php");

Now, at a later time in the page, you wish to load your data from the server. You would just repeat the process:

$(".container").load("../../public/include/menu/add.php");

You're trying to repeat an action at a later time, you would do so by calling the same code again. You can encapsulate it in a function if you don't want to duplicate the code, but overall you just repeat the process any time you want to repeat the results.

Though it's not really clear what you mean by "used the .html thing". And this probably isn't the most performant approach, as you could likely return updated data directly to the AJAX form post instead of requiring another request entirely. But if this is easier for you, go for it.

Upvotes: 3

Related Questions