After calling ajax, when I click on any page, we go to the beginning

I made an ajax call to search for entries. After the result is obtained from ajax, when I try to click on it, the page will move up.

My function to call ajax:

 function ajax_search_primarycare(keyword, userId){
    if(keyword.length >= 3){
         var pricareId = jQuery('#primarycare_provider_id').val();
         var pricareName = jQuery('#primarycare_provider_name').val();
         var pricareStatus = jQuery('#primarycare_icon_status').val();
         var primary_badge_status = jQuery('#primary_badge_status').val();

     $.ajax({type: "POST",
            url: "ajax_search_primarycareprovider.php?keyword="+keyword+"&userId="+userId+"&pricareId="+pricareId+"&pricareName="+pricareName+"&pricareStatus="+pricareStatus+"&primary_badge_status="+primary_badge_status,
            success: function(msg){

            $("#sect_primarycare").html(msg);
            }
        });
return false;
    }

I added return false after calling ajax, but still no result.

Thanks in advance

+4
source share
4 answers

, , "#"? , "#". , ( #), false. Ajax-call false , , , ? - , false.

: user2675751 .

0

( , , ) return false; .
javascript:void(0); href
.

0

!

the result of the function is ajax_search_primarycareinvalid, so you can say that you are calling this function with something like this

$("#subbmit").click(function() {
   ajax_search_primarycare('k',1);
});

you need to return false with this function

$("#subbmit").click(function() {
   return ajax_search_primarycare('k',1);
});
0
source

change your success callback to this:

success: function(msg){
    $("#sect_primarycare").html(msg);    
    $("#sect_primarycare").find('a').on('click', function(e) {
        e.preventDefault();
    });
}
0
source

All Articles