I'm struggling to convert the following from using .load to .ajax which I need to do as I'd like to use ajaxComplete to initiate a plugin after an ajax call has been made.
below is the current code I have, and I need some guidence on how to convert it as I've reached a brick wall.
$('.pbd-alp-placeholder-'+ pageNum).load(nextLink + ' .post',
function() {
// Update page number and nextLink.
$( this ).hide().fadeIn(500);
pageNum++;
nextLink = nextLink.replace(/paged[=].[0-9]*/, 'paged='+ pageNum);
// Add a new placeholder, for when user clicks again.
$('#pbd-alp-load-posts')
.before('<div class="pbd-alp-placeholder-'+ pageNum +'"></div>')
$.ajax({});
// Update the button message.
if(pageNum <= max) {
$('#pbd-alp-load-posts a').text('Load More Posts');
$('#contentWrapper').stellar('refresh');
} else {
$('#pbd-alp-load-posts a').text('No more posts to load.');
}
}
);
$(element).load( url [, data ] [, complete(responseText, textStatus, XMLHttpRequest) ] )
can be converted in to this
$.ajax(function(){
url:"",
data:{},
complete:function(responseText, textStatus, XMLHttpRequest){
}
});
with this you can convert it little by little =)
Example:
$("#myelemdiv").load("/not-here.php",{"mydata":"hellodata"} function(response, status, xhr) {
});
can be converted into like this
$.ajax(function(){
url:"/not-here.php",
data:{"mydata":"hellodata"},
complete:function(response, status, xhr){
$("#myelemdiv").html(response);
}
});