Example of using Ajax with PHP.
Code:
inc_header.php
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Carregamento de Pagina em Ajax</title>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function(e) {
$(".content").load("inc_meio.php");
});
</script>
</head>
<body>
<section class="content">
inc_rodape.php
</section>
</body>
</html>
inc_meio.php
<?php
// pode conter programação também ...
echo date("d/m/Y");
echo "<br />";
?>
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
carregando com ajax<Br />
index php.
<?php
include 'inc_header.php';
include 'inc_rodape.php';
Functioning
In inc_header.php you have a script like this
$(document).ready(function(e) {
$(".content").load("inc_meio.php");
});
who is responsible for carrying with ajax the inc_meio.php. By calling index.php, she will include the inc_header.php and the inc_rodape.php, staying as dynamic inc_meio.php or any other page you prefer
In that link, has several examples with load. It also has the $.post, $.get, $.getJSON and the main $.ajax on the website jQuery
Rendered Page

Where an arrow has been rendered via ajax (jQuery.load), you should always render parts and fix some.
Déa, it seems to me a problem of
path. Can open the pageteste.phpdirectly in the browser?– Sergio
Hi Sergio, open normally!! :(
– Déa
Déa, there is some
echophp? because if you want to load the file then it needs to "run" first to send to the ajax request– Sergio
There’s no echo! I don’t understand what you said
– Déa
Have you tried as the
.load()? Thus:$('.content').load("teste.php"). Replacing the$.ajax()whole.– Sergio
What’s inside that header include?
– bfavaretto
bfavaretto, has the top of the web system(header to be more specific)
– Déa
I tried, Marcelo! Nothing for nothing
– Déa
The problem is difficult to diagnose. Could you make your test available at an accessible address? Or create a Minimum, Complete and Verifiable Example which reproduces the problem?
– bfavaretto
In fact, The Script seems correct, it could post the Developer Tools error in the HTTP request to see the error.
– ooredroxoo