简体   繁体   中英

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>

Change script tag to this

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

ie you're missing ); at the end

Also, document should not have quotes on it

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.

You've forgotten the closing bracket:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM