and I want to include inside a PHP file using jQuery. I am...">

How to include php file using jQuery?

I have a div:

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

and I want to include inside a PHP file using jQuery.

I am trying with this but not working:

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

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

Does this return me PHP code as a string?

+5
source share
2 answers

You can use .load:

$("#content").load('/about_me.php');
+13
source

Is this a .php file? IF this is a .js or .html file, Apache (or any other web server that you use) will not interpret it as a PHP file and will not include the corresponding file.

+2
source

All Articles