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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.