Support » Plugin: Login With Ajax » AJAX Function works only once

  • grafistape

    (@grafistape)


    Hi There im using this function to load a post preview on the same page, everything goes well so far im able to send the post id and get back, the problem is that i have Ajax filters on the same ponting to the same listing grid, and this function works only when the page is load for the first time, if apply some filter this function doesn’t work
    Im using a Listing Grid built with JetEngine and JetSmartFilters

    Any suggestion?

    
     jQuery(document).ready(function(){
        jQuery(".jet-listing-dynamic-link__link").on("click", function(e){
    		e.preventDefault();
    		var url = jQuery(this).attr('href');
    		var id = url.match(/id=(\d+)/)[1];
                    console.log(id);
    		
    		jQuery.ajax({
                    type : "post",
                    url : 'https://addera.pe/prueba/wp-admin/admin-ajax.php',
                    data : {
                        action: "notify_button_click", 
                        message : "Button has been clicked!",
    	            id_post: id
                    },
                    error: function(response){
                        console.log(response);
                    },
                    success: function(response) {
                        jQuery('#txtMessage').text(response.message);
               }
           })
    		
        });
    });
    
    
Viewing 1 replies (of 1 total)
  • timrv

    (@timrv)

    Hello,

    The code you mentioned doesn’t seems like it belongs to our plugin. I think it would be better to ask the Developers of Listing Grid/JetEngine and JetSmartFilters for this one.

    The code you mentioned seems to be correct to me, However I can’t say certainly why it’s only firing once.

    Since you have added a console.log, You should be able to see on until which part is only firing once. in case it’s only firing only until the “console.log(id);” then the issue is somewhere with the on click. I would suggest changing it to something like:

    jQuery('.SOME-PARENT-WRAPPER').on( 'click', '.jet-listing-dynamic-link__link', function() {
    SOME CODE HERE
    });
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.