vikmalhotra
vikmalhotra

Reputation: 10071

Use of ajax framework to develop a webapp employing php, codeigniter

I am going to start developing a webapp using php framework codeigniter. The app is going to do most of the database dealing using ajax/jquery. From what I know, I would be implementing the following steps to do a particular task

  1. Create a view page
  2. The events performed on view page's elements, i.e., click, mouseover etc. will be attached to event handler functions in js files included in the view
  3. js functions will be making get, post requests to server side
  4. In case some dynamic values need to be passed to js functions they'll passed using inline php code given below.
  5. On server side, some database queries will be performed to generate a json(sometimes xml) which will be sent as response
  6. Based on the response, the js function callback will manipulate the dom.

Now, my question is whether there is an ajax framework that can further simplify the implementation of steps given above. if not a framework, then may be a better approach to implementing ajax and php.

// This is part of view page
<a href="Delete User" onclick="deleteUser('<?php echo $userid; ?>')" />

Upvotes: 0

Views: 909

Answers (3)

Phil Sturgeon
Phil Sturgeon

Reputation: 30766

Welcome to jQuery. This is not an AJAX framework (I have never heard of one of those) but it is a JavaScript Framework that incorporates some easy AJAX functionality.

Everyone talks about "integrating with the PHP framework!" like its some sort of crazy feature in PHP. JavaScript makes a request to a URL and does something with the response. That URL could be native PHP, CodeIgniter, a static file or bloody ColdFusion, it is all the same.

So if you are using CodeIgniter, in your view put:

$.get('/controller/method/param1/param2', function(data) {
  $('div#someid').text(data.whatever);
}, 'json');

Upvotes: 4

kevtrout
kevtrout

Reputation: 4984

Codeigniter has a javascript class that might help avoid "the Mess" you spoke of.

http://codeigniter.com/user_guide/libraries/javascript.html

Upvotes: 0

Jamie Wong
Jamie Wong

Reputation: 18350

I don't really know what you mean by "AJAX framework" and whether you're talking about a clientside or serverside framework.

In the event you're looking for a clientside framework that handles client-server data synchronization, check out http://documentcloud.github.com/backbone/

Upvotes: 1

Related Questions