Im trying to include a file on my server using AJAX, the only problem is that it stops my php code from working.
the page im using ajax at:
<div id="content">
<!--- HERE GOES CONTENT --->
</div>
<script>
$.ajax({
url: 'https://mywebsite.com/func/contentpage.php',
dataType: 'html'
})
.done(function(data) {
// Assuming the request returns HTML, replace content
$('#midten').html(data);
});
</script>
contentpage.php codes
<?php
$g1 = $database->query("SELECT * FROM `users` WHERE `sesid` = '" . $_SESSION["uises"] ."' AND abd='" . $_SESSION["uiabd"] ."'");
$ui2 = $g1->fetch_object();
echo $ui2->name;
?>
The code above should echo a name from the database but for some reason it does not.
if i use php and include the page like this: include("/func/contentpage.php");
it echo the name whitout any problems
but when trying to load the page whit ajax it does not echo a name or anyhting.
The reason im using AJAX is to load content when buttons is clicked whitout the browser having to reload.
any one know how i can solve this probelm whit AJAX or know another method i could use in php to change the path in include whitout having to reload the webpage/load the whole website again.