-
Notifications
You must be signed in to change notification settings - Fork 0
YUI Ajax Helper
Category:Helpers | Category:Helpers::Ajax
This is a simple helper that extends the default form helper, and it adds a function to transform a simple form into an ajax one, it only needs the id of the form you want to upload, optionally you can give it a second paremeter, as if you dont specify this, it will send a POST request, you can change this to POST or GET. The third argument is an id of a div layer, if specified, the result of the request will go there, the fourth argument is a boolean value, if true it will make the div automatically, if false, it will assume you already have a form like that in your code, default is true.
Helper: [url]http://pastebin.com/f72c7d780[/url]
Here is a simple example
[code]<?php /**
- Ajax Test Controller */ class Test extends Controller { function index() { if($_POST) print_r($_POST); else { $this->load->helper('form'); echo form_open('test', array('id'=>'form')); echo form_input('title'); echo form_submit(array('name'=>'Submit', 'id'=>'Submit', 'value'=>'Submit this')); echo form_close(); echo form_ajax('form', 'POST', 'updateDiv', true); } } }
/* End of test.php / / Location: ./system/application/controllers/test.php */[/code]