To extend the 'loadqposts' function with another function that can be defined by developers later, you can modify the function to accept an optional parameter that represents the additional function. Here's an example of how you can do that:

function loadqposts(getdata, additionalFunction) {
	
	  $.ajax({
      type: 'POST',
      url: qqajaxurl,
      data: {'action' : 'qq_posts_loadX','urldata' : getdata},
      dataType: 'html',
	  beforeSend : function () {	
        if ($('.loadingis').length === 0) {
            $('.paging-content').append('<div class="loadingis"><div class="infinityChrome"> <div></div> <div></div> <div></div> </div></div>');
        }  
        $('.noproduct').hide();
	  },
      success: function(d_page) {
        $('.loadingis').remove();
        $('.paging-content').html(d_page);
        $('.qloop_content_fake').hide();
        $('.qloop_content').show();
        $('.paging-content').removeClass('qblurr');
        
        if (additionalFunction && typeof additionalFunction === 'function') {
            additionalFunction();
        }
      },
      error: function(d_page){
        $('.loadingis').remove();
        $('.paging-content').removeClass('qblurr');
        console.log(d_page);
      },
    });
		
		return false;	
	
}

With this modification, you can pass an additional function as the second argument when calling 'loadqposts'. If the 'additionalFunction' parameter is provided and is a valid function, it will be executed after the AJAX request is successful. Developers can define their own function and pass it to 'loadqposts' to extend its functionality.


原文地址: https://www.cveoy.top/t/topic/p1iu 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录