Jump to content

Add AJAX?


birdbrain24

Recommended Posts

How could i add AJAX to this page so that when the POST methos page is changed it will just get the new include instead of having to reload the page?

 

Also if it can not work how my page is set up i am willing to change my page to make it work! So if anyone could help please do so!

 

Thanks!

 

<html>
<head>
<title>RACE</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="javascript.js"></script>
</head>
<body>
<?php
# Common functions!
session_start();
include 'functions.php';
connect();
sessioncheck();
lastaction();
?>
<table align="center" cellspacing="5">
  <tr>
    <td align="right" width="175" style='vertical-align: top; padding: 0px;'><?php require_once 'menu.php'; ?></td>
    <td align="center" style='vertical-align: top; padding: 0px;'><?php if(isset($_GET['page'])): 
                              
                              $page = $_GET['page'];
                              $file_to_include = $page . ".php";
  
                              if(file_exists($file_to_include)): 
  
                              include($file_to_include);

                              else:
  
                              header('Location: index2.php?page=news');

                              endif;

                              else:
  
                              header('Location: index2.php?page=news');

                              endif; ?></td>
    <td align="left" width="175" style='vertical-align: top; padding: 0px;'><?php require_once 'stats.php'; ?></td>
  </tr>
</table> 
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/89469-add-ajax/
Share on other sites

 

You need to add your includes and any other code that help the includes function and then add your ajax to another page. You would set your ajax up to query the include php page (that you just created) and your ajax's http.responseText will return your php include's content to your page (that contains the ajax script). My suggestion is for you to read up on some tutorials and examples to see how ajax works with php.

Link to comment
https://forums.phpfreaks.com/topic/89469-add-ajax/#findComment-458605
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.