0

Well, I've created a code to include a PHP page in a box and not only the normal include ('');

This is my code:

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
    <script>
        $(function() {
            var count = 1;
            $('#append').click(function() {
                if (count < 2) {
                    $('#parent').append('<div id="first' + count + '">text</div>');
                    $('#first1').load('../image/index.php');
                    count++;
                }
            });
        });
    </script>
    <a id="append">Add DIV 1</a>
    <div id="parent">
    </div>
</body>
</html>

Now, I've noticed I could "load" a page in html, but all the php and javascript code is "out". How do I do to have the "real" page inside another.

1
  • $.get() should work. Commented May 17, 2013 at 13:22

2 Answers 2

1

The PHP code is not returned since it is executed on the server before you get the HTML back from it. In order to just retrieve it as plain text you will need to change the file you are trying to retrieve.

As far as how to load a page inside another page, you can use iframes for that.

Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

<script>
$(function(){
  var count = 1;
  $('#append').click(function(){
      if (count <2){
         $('#parent').append('<div id="first'+count+'">text</div>');
         $.get('http://test.com/image/index.php',function(data){
             $('#first1').html(data);
         });
         count++;
      }
  });
});
</script>

2 Comments

in the case, the output will be "/image/index.php" and not the page itself
Does index.php echo any content?

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.