var row_limit = 50; var curr_params = ''; // params from currently displayed search, for pagination function getResults(use_old, page) { //if undefined, set default use_old = typeof use_old !== 'undefined' ? use_old : false; page = typeof page !== 'undefined' ? page : 1; var elem = document.getElementById("sportsmenForm").elements; var params = ""; url = realUrl + path + "/getResults.php?&games_id=" + games_id + "&page=" + page; // if new search if (!use_old) { for (var i = 0; i < elem.length; i++) { if (elem[i].tagName == "SELECT") { params += elem[i].name + "=" + encodeURIComponent(elem[i].options[elem[i].selectedIndex].value) + "&"; } else { params += elem[i].name + "=" + encodeURIComponent(elem[i].value) + "&"; } } } else params = curr_params; // if same search, different page // ajax request var http_request = new XMLHttpRequest(); try { // Opera 8.0+, Firefox, Chrome, Safari http_request = new XMLHttpRequest(); } catch (e) { // Internet Explorer Browsers try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { // Something went wrong //alert("Your browser broke!"); return false; } } } http_request.onreadystatechange = function () { if (http_request.readyState == 4) { //console.log(http_request.responseText); result = JSON.parse(http_request.responseText); //console.log(result); content = result['content']; out = ''; // switch for dark background in every secound line tblLine = true; var counter = (page - 1) * row_limit; for (e in content) { counter++; tblLine = !tblLine; out += '