7

This should work right? I have not a clue as to why it's not. I have to be doing something wrong.

<div id="randomdiv">text</div>
    <a id="refresh">click</a>

    <script>
    $(function() {
      $("#refresh").click(function() {
         $("#randomdiv").load("index.php")
      })
    })
    </script>
2
  • Can I use this function say, from a child page to a parent page? Commented Oct 3, 2011 at 22:23
  • Does this answer your question? Onclick refresh only div Commented Jul 8, 2020 at 11:20

1 Answer 1

18

What happen if you do this?

<a id="refresh" href="#">click</a>

<script>
    $(function() {
      $("#refresh").click(function(evt) {
         $("#randomdiv").load("index.php")
         evt.preventDefault();
      })
    })
</script>
Sign up to request clarification or add additional context in comments.

1 Comment

What if the div I'd like to refresh is a Google map for instance. How do you go about doing that?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.