Cjax Framework


Passing Parameters

Passing Element Values in the URL

Sometimes you might need to pass element values such as these of a text field or checkbox or a hidden field. You can easily pass fields values without submitting a form. To accomplish this, in the url pass the element_id wrapped with vertical bars.

PHP

ajax.php?controller/function/arg1/arg2/|text1|/|checkbox1|
The above URL will automatically seek for these elements on the HTML document and pass their value in the URL.

Using Data Attribute

You can also pass parameters within the data-x attribute.
Just add any data-x item in the element target. When clicked, it passes that value in the parameter in the URL. This works in a similar way you pass field values, instead of adding the |field_name|, you add |data.name|.

PHP
<?php 

    $ajax
->click('#button1'$ajax->call('ajax.php?params/data/|data.my_name_is| - |data.cj|'));
    
$ajax->click('#button2'$ajax->call('ajax.php?params/data/|data.yes|/|data.id|'));
    
?>
HTML
    <input type="button" id="button1"  data-my_name_is="My Name" data-cj="is Cj!" value="Click this button to make an ajax request #1">
    <input type="button" id="button2" data-yes="Yes," data-id="This is an ID!" value="Click this button to make an ajax request #3">
    

Try it



Previous Topic:  Previous Class    ·   Top of Page   ·   Demos Home   ·  

CodeIgniter  ·  Copyright © 2006 - 2012  ·  Cjax