www.webdeveloper.com
Results 1 to 2 of 2

Thread: Help with Loading JSON into PHP with ajax/jquery

  1. #1
    Join Date
    Jul 2009
    Posts
    1

    Post Help with Loading JSON into PHP with ajax/jquery

    I am trying, as a new developer, wrap my head around the best approach to load a JSON file, create some sort of template with variables or placeholders, without using jquery to build DOM elements, since its a complex div.
    To make it more complicated I would like to have a onClick event to a set of tabs in this case dates (since this is a event calendar) and have it load 5 events for each date, without reloading the page, which is where ajax comes in.

    Here is my JSON function:

    Code:
     function getEvents()
        {
        $foo['events'] = 
    		array(
    		array('id'=>'1', 'title'=>'My Title'),
    		array('id'=>'2', 'title'=>'My Title2'),
    		array('id'=>'3', 'title'=>'My Title3'),
    		array('id'=>'4', 'title'=>'My Title4'),
    		array('id'=>'5', 'title'=>'My Title5')
    		);
    		echo json_encode($foo);
    		}
    Any help in getting this working or some way help me understand the best way to do this, would be greatly appreciated.

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    that's php, not javascript.
    if $foo is a global, tell php so, otherwise, delclare $foo first, then assign the events array to foo...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles