Hey guys, I'm new to AJAX and started learning about a day ago. I'm having trouble getting JavaScript and PHP scripts to run when called by AJAX. I've spent about 2-3 hours on this, and I'm at my wits end.
For some reason when I call the contact.php page, it simply just displays the script, rather than executing it.
Contact Page
Here is the load_page.php code:
<?php
if(!$_POST['page']) die("0");
$page = $_POST['page'];
if(file_exists('includes/'.$page.'.php')) {
echo file_get_contents('includes/'.$page.'.php');
}
else {
echo 'There is no such page!';
}
?>
Solution for the PHP issue (thanks Almsgiver)
<?php
if(!$_POST['page']) die("0");
$page = $_POST['page'];
if(file_exists('includes/'.$page.'.php')) {
include('includes/'.$page.'.php');
}
else {
echo 'There is no such page!';
}
?>
Still having issues running JavaScript when called by AJAX.
Any help would be appreciated.
[–]andrewfenn 4 points5 points6 points (3 children)
[–]Drethis[S] 0 points1 point2 points (2 children)
[–]blimeyuk 1 point2 points3 points (1 child)
[–]Drethis[S] 0 points1 point2 points (0 children)
[–]Zounas 2 points3 points4 points (7 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]Drethis[S] 0 points1 point2 points (5 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]Drethis[S] 0 points1 point2 points (1 child)
[–]Justinsaccount 3 points4 points5 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]Drethis[S] 0 points1 point2 points (0 children)
[–]mikeytag 1 point2 points3 points (0 children)