To extend the loadqposts function with another function, you can modify the function definition to accept an additional parameter for the new function and then call that function within the success callback of the AJAX request. Here's an example of how you can do it:

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');
		
		// Call the additionalFunction here
		additionalFunction();

		return false;
      },
      error: function(d_page){
		$('.loadingis').remove();
		$('.paging-content').removeClass('qblurr');

		console.log(d_page);
		return false;
      },
    });
		
	return false;	
	
}

// Example usage
function additionalFunction() {
	console.log("This is the additional function");
}

loadqposts(getdata, additionalFunction);

In this example, the loadqposts function now accepts an additional parameter additionalFunction, which is the function you want to extend with. Inside the success callback, after updating the content and removing the loading animation, the additionalFunction is called

function loadqpostsgetdata 		 $ajax type POST url qqajaxurl data action qq_posts_loadXurldata getdata dataType html	 beforeSend function 	if $loadingislength === 0 	 	 $pag

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

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