reload div after ajax request

You can load the div like this.Please mind the space before divid (" #divid");

if (data.success){
   $("#divid").load(" #divid");
    }

I know this post is old and already answered. But I would Like to add something to it. If you look at the answer of @Sree KS it will load the div on top of the existing div. Which is not ideal. Just run inspect div after the method is completed.

To avoid this issue use the following code:

$("#divid").load(" #divid > *");

Hope this will help to anyone who has the same issue.


I think you are trying to reload the header section after login to show the username, logout etc. To do that you have to return the all html from the your ajax method into the "data.success" variable using like json encode.

your ajax method function () {
    $response = array('success' => 'Your html data come here');
    echo json_encode($response);
    exit(0);
}