HI all,
i have a links which is dynamically created.after clicking this link only one ajax request has to go for retrieving relevant broker data.but after seeing in firebug it displaying sometime 3 request and some time 5 request of ajajx call. i need only one ajax call on click of that link.... i am using CI ....

<a onclick="getfol('All','1','http://localhost/final_tra/index.php/cpanel/usercp_folder/disfolder/Broker/2/');" style="cursor:pointer;" class="defaultalldoc" id="Broker-2"><img src="http://localhost/final_tra/images/cpanel/left_bar_arrow.png">Broker</a>

my ajax fun

jQuery(document).ready(function(){
        $('#defaultalldoc').click(function(){
           
           var defaultallsrch='<?php echo $this->config->item('base_url') . '/index.php/cpanel/usercp_task/disfolder/All/1'; ?>';
            $.ajax({
                type: "POST",
                url: defaultallsrch,
                cache: false,
                
                success: function(data) {
                   //alert(data);
                }
            });

        })

    }
);

any help appre

thanx

Member Avatar
diafol

You should be using the class not the id so:

jQuery(document).ready(function(){
        $('.defaultalldoc').click(function(){
 
           var defaultallsrch='<?php echo $this->config->item('base_url') . '/index.php/cpanel/usercp_task/disfolder/All/1'; ?>';
            $.ajax({
                type: "POST",
                url: defaultallsrch,
                cache: false,
 
                success: function(data) {
                   //alert(data);
                }
            });
 
        })
 
    }
);

Use the dot (.) instead of the hash (#). Also should the url have a php extension?

url: "defaultallsrch.php"

You should be using the class not the id so:

jQuery(document).ready(function(){
        $('.defaultalldoc').click(function(){
 
           var defaultallsrch='<?php echo $this->config->item('base_url') . '/index.php/cpanel/usercp_task/disfolder/All/1'; ?>';
            $.ajax({
                type: "POST",
                url: defaultallsrch,
                cache: false,
 
                success: function(data) {
                   //alert(data);
                }
            });
 
        })
 
    }
);

Use the dot (.) instead of the hash (#). Also should the url have a php extension?

url: "defaultallsrch.php"

thanx for help basically i am using codeigniter frmwork . so i dont want to pass extendsion on url... why not pass #?

Member Avatar
diafol

Sorry didn't read it properly. Your url looks ok - I didn't realise that it was a var. However the jquery syntax is like css for class and id. If you want to link to the anchor id use #broker-2