5

I have that div:

<div id="content"></div>

and I want to include inside PHP file using jQuery.

I try with this, but doesn't work:

var about_me = "<?php include('php/about_me.php') ?>"

$('$content').click(function(){
 $('#content').text(about_me);
});

This returns me PHP code like a string?

0

3 Answers 3

17

You could use .load:

$("#content").load('/about_me.php');
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, this works! If I have some questions, I will write here. Thanks!
2

Is it a .php file? IF it's a .js or .html file, Apache (or whatever webserver you're using) won't interpret it as a PHP file and won't include the relevant file.

Comments

0

this is a simple way that you can do it. Just do it.

just put the file name in .load function

$(function(){  $("#includedContent").load("header.php"); });

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.