user3337079
user3337079

Reputation: 11

How to load php code into html tag DIV using Jquery?

I am trying to load php code into div tag to show the results but the below code doesn't work for.

Can anyone please help me...to resolve this

my code is below:

<html>
<head>
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
$("document").ready(function()
{ 
   $("#myDiv").load("refreshing.php");      
}
</script>
</head>
<body>
   <div id='myDiv'> </div>
</body> 
</html>

Upvotes: 1

Views: 2573

Answers (3)

esviko
esviko

Reputation: 358

You've forgotten the closing bracket:

$("document").ready(function(){
    $("#myDiv").load("refreshing.php");
});

Upvotes: 0

Onimusha
Onimusha

Reputation: 3385

Change script tag to this

<script type="text/javascript">
$(document).ready(function()
{ 
   $("#myDiv").load("refreshing.php");      
});
</script>

i.e. you're missing ); at the end

Also, document should not have quotes on it

Upvotes: 1

suenda
suenda

Reputation: 783

You cannot load php code .load() because as the web server gets the GET request with .php, the request is passed to PHP interpreter which will execute the PHP script and return the result of the php script instead of code. So what you can do is in your PHP script, do a echo of all the code that you want to display. Or, you can define custom rule in your Apache configuration.

Upvotes: 0

Related Questions