samedi 29 novembre 2014

jquery ajax post href value without refreshing the page


Hello I want to post link value e.g. href="?id=1" my link


but without refreshing the page current it refreshes the page but i dont want reloading of the page, here is my code please help me



function loadTabContent(tabUrl){
$("#preloader").show();
jQuery.ajax({
type: post,
url: tabUrl,
data: "id="+country_id,
cache: false,
success: function(message) {
jQuery("#tabcontent").empty().append(message);
$("#preloader").hide();
}
});
}

jQuery(document).ready(function(){

$("#preloader").hide();
jQuery("[id^=tab]").click(function(){

// get tab id and tab url
tabId = $(this).attr("id");
tabUrl = jQuery("#"+tabId).attr("href");

jQuery("[id^=tab]").removeClass("current");
jQuery("#"+tabId).addClass("current");

// load tab content
loadTabContent(tabUrl);
return false;
});
});




Aucun commentaire:

Enregistrer un commentaire