I'm using AJAX for these tasks. Now as you know you put the PHP page which handles those tasks the the AJAX function's url.
$.ajax(
{
type : 'GET',
url : 'requestPage.php',
//rest of the code
});
requestPage.php looks like this
<?php
include_once 'DatabaseHandler.php';
$db = DatabaseHandler::getInstance();
//loading records
try
{
//code for loading records
echo json_encode($results);
}
catch (Exception $e)
{
echo $e->getMessage();
}
//generating a new ID
try
{
//ID generating code
}
catch (Exception $e)
{
echo $e->getMessage();
}
?>
Is it possible to put all the code which handles different tasks into a single PHP page and when an AJAX call requests for a certain task, the page find the code which does the requested one and returns its results?
if loading_records Is called
execute the code for loading records
and return the results
else if new_id Is called
execute new ID generating code
and return the result
Thank you

New Topic/Question
Reply


MultiQuote





|