Oct
7

AJAX in PHP for fresh $_GET’s

Author admin    Category Web Development     Tags

If you are having trouble showing fresh content from PHP/MySQL in AJAX, try this out!

First, you must obviously include JQuery lib.

Then, using Jquery set an AJAX load in your View or Template:

<script type="text/javascript">
<span>(document).ready(function(</span>) {
<span>
     $("#element").load("stuff.</span>php?idea");
 
});
</script>
 
<div id="element"></div>

Then get the php file you are loading, in this case its stuff.php, and create a get request for the value passed in the URL, which is 'idea'.

if (isset($_GET['idea']))
{
  echo 'Ajax is working';
  //
  // All your functions in here
  //
  exit; // Make sure to exit so nothing else processes.
}

Post comment

Recent Posts

Archives

Your Ad Here