SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    AJAX PHP variable request

    I have a graph that i need to be dynamic in the sense that a user would click a checkbox and select which info will be displayed. I can do this using php, but i want a seamless transition done. My thoughts are AJAX SO basically i need a way to send a a request to a php page lets say graph.php with a variable set liek so:

    graph.php?id=1

    Can someone point me in the right direction regarding this please, i presume i can use the onCheck on the check box and have a small function to handle the ajax request, Just to summerize:

    Checkbox Clicked --> Request to php page with a variable set --> Return the php page.

    Thanks for the help in advanace
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi There,

    I just had a similar issue and there are a lot of "packages" out there that can help you do this.

    I found one called PHPLiveX that is very lightweight and does only exactly that - executes a PHP function and returns the return value for you to write with JavaScript.

    There are a few examples included with the package - take a look:

    http://phplivex.sourceforge.net/
    Soren Beck Jensen

    http://www.automaticbacklinks.com - Free link exchange network
    http://www.notwebdesign.com - Joomla web design in Spain

  3. #3
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, lots of Ajax libraries out there to help you out.
    Check out http://mootools.net
    and you can do something like
    Code:
    //xhtml
    <input type='checkbox' value='foo' onclick="
    new Ajax('http://yoururl/ajaxpage.php', {method:'post',postBody:'id='+this.value,onComplete:ajaxCallback{).request()" />
    
    //js
    //the php page should return back xml
    function ajaxCallback(obj) {
        this.transport.responseXML.getElementsByTagName('bar')
        ...
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •