NYCPHP Meetup

NYPHP.org

[nycphp-talk] javascript calling php function -- now question on Ajax

Susan Shemin susan_shemin at yahoo.com
Tue Feb 19 01:55:03 EST 2008


thanks, Steve

I'll have to work through your example.  And thanks so much for pointing me to xAjax -- I'll look it over.


----- Original Message ----
From: Steve Manes <smanes at magpie.com>
To: NYPHP Talk <talk at lists.nyphp.org>
Sent: Monday, February 18, 2008 8:36:28 PM
Subject: Re: [nycphp-talk] javascript calling php function -- now question on Ajax

Susan Shemin wrote:
> Anyway, Ajax is usually used to open an external file into a div, and it 
> uses a form to send the request.  What I want to do is trigger a php 
> script to run when someone clicks a certain anchor URL.  I guess you 
> would call it my own stats attempt.  So I have no form, and nothing to 
> be displayed on the current page because the user is going to URL from 
> the click.
>  
> Please be gentle with me -- but what am I missing and is it at all 
> possible, Ajax or not?

Sure.  Here's an excerpt of something similar using xAjax in a project 
I'm working on now:

/* HTML */
<a href="javascript:void(null)"
    onclick="this.blur();
            div_off('id_add_note_off');
            xajax_load_contact_notes_server('id_view_note',
            'id_view_note_on', {$notes[i].contact_note_id});
            return false;">
  <img src="/images/icons/edit.gif" border="0" alt="edit"></a>


/* PHP */
function load_contact_notes_server($container_id, $div_id, $contact_note_id)
{
    global $trms;

    $ajax_response = new xajaxResponse();

    // Load vendor

    list($results, $message) = admin_get_contact_notes($trms, 
$contact_note_id, true);

    // ....

    $ajax_response->assign($container_id, 'innerHTML', 
$trms->fetch('view_contact_note.tpl'));
    $ajax_response->call('div_on', $div_id);

    return $ajax_response;
}

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080218/a2dab1be/attachment.html>


More information about the talk mailing list