0

I am trying to reload some content present inside the div but it can not happen like this. I am providing my code below.

space.php:

<?php
 require_once('header.php');
?>
<div>
    <a href="#">Update the div!</a>
</div>

header.php:

<div class="collapse navbar-collapse navmenu loadListSpaceDiv" id="bs-example-navbar-collapse-1">
<?php
  if(isset($_SESSION['vendor_id'])){ ?>
    <ul class="dropdown-menu dropdown-menu-right">
        <li><a href="<?php echo SITEURL.'vendor';?>">Dashboard</a></li>
        <li><a href="<?php echo SITEURL;?>signout">Sign Out</a></li>
    </ul>
<?php
}
?>
</div>

Here when user will click on anchor tag the above div element should refresh/reload. Here is my code:

$(function() {
    $('a').click(function() {
        $(".loadListSpaceDiv").load(document.URL +  '.loadListSpaceDiv');
    });
});

But its not working as per expected. Here I need when user will click on that a tag the all div content will reload again.

7
  • $(".loadListSpaceDiv")[0] since you are using class as selector i think. Commented Apr 17, 2017 at 14:10
  • Yes,I am using class as selector. Commented Apr 17, 2017 at 14:11
  • Have you tried $(".loadListSpaceDiv").load(document.URL); Commented Apr 17, 2017 at 14:11
  • @ProgrammerV5 : It will reload the total page. I need to load only that section present inside div.Actually I have also other code in that file. Commented Apr 17, 2017 at 14:15
  • By any chance is the space.php file on another domain? Commented Apr 17, 2017 at 14:17

1 Answer 1

1

If you'd wish to jQuery load() only a specific part of the source page, separate the CSS selector from the URL by a space:

$(".loadListSpaceDiv").load(document.URL +  ' .loadListSpaceDiv');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.