Alex:

I think you're looking for something a bit simpler. jQuery, without
the aid of any additional plugins, has all of the tools necessary for
developing an AJAX solution to work with any platform, PHP included.
Below, I've included some example code for how you would accomplish
what you originally asked for (delivering different forms based on
click):

JavaScript:

$(function(){ // Same as window.onload

 $('a').click(function(){ // Same as onclick

   // Send request to input.ajax.php with variables sid and form, then run the
   // following anonymous function on successful completion, 'html' being the
   // output of input.ajax.php
   $.get('input.ajax.php',{sid:<session
id>,form:$(this).attr('id')},function(html){

     // Find div with class formwrapper, empty the contents, append 'html'
     $('div.formwrapper').empty().append(html);

   }); // End get

   // Prevent click propagation
   return false;
 }); // End click

}); // End window.onload

HTML:
<a href="#" id="form1" class="formclick">Form One</a>
<a href="#" id="form2" class="formclick">Form Two</a>
<div class="formwrapper"></div>

PHP (input.ajax.php):
<?php

// Handle session variables using $_GET['sid']

switch($_GET['form']) {
case 'form1':
// echo HTML for Form One
break;
case 'form2':
// echo HTML for Form Two
break;
...
}

?>

Hopefully that helps, you may want to consider reading up on exactly
how AJAX works and the jQuery documentation.

- jake


On 4/16/07, Alex Ezell <[EMAIL PROTECTED]> wrote:

Thanks Richard. I don't know if I am 100% sure how someone puts jqPie
into action. Would I write my handler.php to include all the objects
and session information I need and it interfaces with jQuery?

On 4/15/07, Richard Thomas <[EMAIL PROTECTED]> wrote:
>
> http://projects.cyberlot.net/trac/jqpie
>
> Take a look through there, but basically the ajax calls are browser
> calls so as long as you stay within the same domain anything the page
> would have access to the php called through ajax has access to.
>
> On 4/15/07, Alex Ezell <[EMAIL PROTECTED]> wrote:
> >
> > Is it possible to load a PHP page via AJAX such that the PHP page
> > being loaded has access to the session, objects and variables which
> > exist in the calling page?
> >
> > My situation is that I would like to load one of several different
> > forms (written in PHP) based on which link a user clicks. Essentially,
> > they are selecting what kind of post they want to create and I want to
> > load the appropriate form via AJAX.
> >
> > Those PHP forms use PHP includes, access objects and user in-page
> > variables, so keeping that stuff intact is the goal.
> >
> > Any ideas?
> >
> > /alex
> >
>

Reply via email to