1

I'm trying to reload a div (#parent) when I click on a button (#button). That div contains an external PHP file. The problem I have is that it only works once when clicked.

Here is the code I'm using:

HTML
<div id="parent"> 
    <?php include 'content.php'; ?>
</div>

jQuery
$(function () {
    $("#button").click(function (evt) {
        $("#parent").load("content.php")
        evt.preventDefault();
    })
})

content.php
<button type="button" id="button">Click me</button>
<img src="<?php echo $path . $img ?>" /><!-- loads a random image -->

However, the button that reloads the div is inside the content.php file (due to the design of the site) which I think it's the root of the problem. The jQuery code works fine if the #button is placed outside the #parent div, but I need the button to be inside content.php.

Is there a way to resolve this?

Andres
  • 223
  • 2
  • 8

0 Answers0