Skip to content
Advertisement

Dynamic content [closed]

My index page has a two column layout. In the left I have several icons (links) and in the right the dynamic content. Every time I click in one icon of the left I would like to show related information in the right.

I don’t know if I should use Ajax or something related to CakePHP (I’ve read about requestAction but I think that’s not the right way).

Any suggestions?

Advertisement

Answer

You must know about jQuery and $.ajax in jQuery.

So you can do it this way.

<script type="text/javascript">

    (function($){

        $('LINKS_LEFT').click(function(e){

            e.preventDefault();

            var href = $(this).attr('href');

            $.ajax(
            {
                url         : href,
                dataType    : 'html',
                beforeSend  : function()
                {
                    // show loading or else
                },
                success     : function(response)
                {
                    if(response)
                    {
                        // display it in right side div.
                    }
                }
            });

        })

    });

</script>
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement