Call the ajax function again after Complete function
I'm trying to re-execute the function with other parameter in the complete
callback, but it isn't working as I want. It works well at the first call,
but when I call it again, it only alerts the test alert twice and doesn't
execute the function again. My intention is to execute the function with
another parameter,that is the id of the element every time that the user
click on the element. I appreciate if anyone could help me, what should I
do? Thanks. =)
jQuery(function($){
var load_pages = function($page){
$.ajax({
type : "POST",
data : {page_name : $page},
dataType : "html",
url : "http://localhost/includes/loadpages.php",
beforeSend : function(){
$("#content").addClass("hide");
if($page.substr(0,9) == "categoria"){
$("#content").removeClass("hide");
$("#the-portfolio").remove();
}
},
success : function(data){
$data = $(data);
if($data.length){
if($page == 'lista_portfolio'){
$(".submenu").append($data);
$(".submenu").append('<div class="end"></div>');
}
else{
if(!$("#content") == false){
$("#wrapper").append('<div
id="content"></div>');
}
$("#content").append($data);
$(".foot").animate({bottom:
0},700,'easeOutExpo');
$data.fadeIn(500);
}
}
},
error : function(jqXHR, textStatus, errorThrown) {
alert(jqXHR + " :: " + textStatus + " :: " +
errorThrown);
},
complete : function() {
$("#portfolio_categories_list li a").click(function(){
alert("test");
$categoria = $(this).attr("title").split("Ver
todos os posts arquivados em ");
load_pages("categoria"+$categoria[1]);
return false;
});
}
});
}// end load_pages
});
No comments:
Post a Comment