How can i update global variable URL? I am trying for the last 3 days, still no luck
var output = '';
var pageNum = '';
url = '';
function post_ajax_get(pagination) {
$("#loading-animation").show();
var query = 'nazwa=';
var time = 'gr=';
var output = '';
$("[data-category-menu] a.current").each(function(){
if($(this).data('time')) {
if(time != 'gr=') {
time+= ',';
};
time+= $(this).data('time');
}
if($(this).data('slug')) {
if(query != 'nazwa=') {
query+= ',';
};
query+= $(this).data('slug');
}
if (query != 'nazwa=' && time == 'gr='){
output = query;
}
else if (query == 'nazwa=' && time != 'gr='){
output = time;
}
else if (query != 'nazwa=' && time != 'gr='){
output = time + '&' + query;
}
});
if(pagination) {
$("[data-pagination] a.current").each(function(){
if(output != '') output+= '&';
output+= $(this).data('slug');
});
}
url = window.location.protocol + '//' + window.location.host + '/' + window.location.pathname + '?' + output;
//window.location.href = url;
if ($('body.category').length > 0 && output == '') {
var adres = window.location.pathname;
var cat = adres.split('/')[3];
url = window.location.protocol + '//' + window.location.host + '/' + window.location.pathname + '?' + 'nazwa=' + cat;
$('[data-category-menu] li a').each(function() {
if($(this).attr('id') == cat) {
$(this).addClass('current');
}
$('[data-category-menu] li a.current').click(function() {
$(this).removeClass('current');
})
})
}
$('[data-category-menu] li a.current').click(function() {
updateURL();
})
function updateURL() {
console.log('fire');
url = window.location.protocol + '//' + window.location.host + '/' + window.location.pathname + '?' + 'nazwa=pusty';
}
console.log(url);
var pageNum = url.substr(url.indexOf("md_page=") + 8);
//var pagNum = pageNum.toString();
$('#md-products').load(url + ' #md-products > *', function() {
$("#loading-animation").hide();
$('#md-products [data-pagination] a').on('click', function() {
$(this).addClass('current');
post_ajax_get(true);
})
});
}
console.log(url);