Welcome Guest, Not a member yet? Register   Sign In
Does Code Igniter has build in Ajax Support
#1

[eluser]ummarbhutta[/eluser]
Hi,
I am new to Code Igniter? want to know that whether CI has built in support for Ajax or we have to use some third party library....
Thanks
#2

[eluser]Pascal Kriete[/eluser]
As of right now the framework is purely php - no javascript, so you will still need to write that yourself. However, an official jQuery library has been announced and should be out in the next few months.

Welcome to CodeIgniter.
#3

[eluser]xwero[/eluser]
The jQuery library is actually a wrapper library where you can add any javascript library you want to use in php.

I prefer do keep my javascript coding separate from the php programming as much as possible because most of the time it's not ajax related.
#4

[eluser]ummarbhutta[/eluser]
Thanks for reply..
#5

[eluser]WoOzY KinG[/eluser]
@xwero: does jQuery's core come with some juicy features as well? That's what I always thought.
#6

[eluser]xwero[/eluser]
The most appealing feature for me is making javascript more easy to work with and understand. But of course there is the dom parser/engine that is the heart of jQuery and the fact that you can extend it to you liking with plugins, you can write yourself if you want.
#7

[eluser]WoOzY KinG[/eluser]
@xwero: Actually we have the same reason of using it. Sorry that I've always included the plugin that their team developed as well. So what I mentioned was like jQuery + their plugins.
#8

[eluser]Lukifer[/eluser]
I rolled my own AJAX helper, using Prototype rather than jQuery (both are quite good, I just have more experience with the former). Here it is, in case you find it helpful:

Code:
# AJAXANCHOR: Creates link which hits URL and replaces the contents of provided CSS id
# Usage: echo ajaxAnchor('css_id_to_update', 'http://url/here', 'Name of Link');
if(!function_exists('ajaxAnchor'))
{
    function ajaxAnchor($div, $url, $label, $more = '')
    {    return '<a href="#" onclick="new Ajax.Updater(\''.$div.
            '\', \''.$url.'\'); return false;" '.$more.'&gt;'.$label.'</a>';
    }
}

# TOGGLELINK: Creates link that shows/hides provided CSS id
# Usage: echo toggleLink('css_id_to_toggle', 'Name of Link');
if(!function_exists('toggleLink'))
{
    function toggleLink($div, $label, $more = '')
    {   return '&lt;a href="#" onclick="$(\''.
        $div.'\').toggleClassName(\'hidden\'); return false;" '.
        $more.'&gt;'.$label.'</a>';
    }
}

# AJAXFORM: Create simple form that posts with AJAX
# Usage: echo ajaxForm('css_id_to_update', 'http://url/to/post/to');
if(!function_exists('ajaxForm'))
{
    function ajaxForm($div, $url, $more = '')
    {    return '&lt;form action="'.$url.'" onsubmit="new Ajax.Updater(\''.
         $div.'\', this.action, {parameters:this.serialize(),evalScripts:true});'.
         'return false;" method="POST" '.$more.'&gt;';
    }
}

# AJAXLOAD: Immediately fires AJAX call, replacing content of CSS id
# Usage: echo ajaxLoad('css_id_to_load_in', 'http://url/here');
if(!function_exists('ajaxLoad'))
{
    function ajaxLoad($div, $url)
    {    return 'new Ajax.Updater(\''.$div.'\', \''.$url.'\');';
    }
}

EDIT: ajaxLoad string should be wrapped in script tags, the forum is eating them. Tongue

Looking forward to CI/EE 2.0's abstracted JS libraries! Smile




Theme © iAndrew 2016 - Forum software by © MyBB