tyra Posted December 9, 2010 Share Posted December 9, 2010 Can someone add 2 second delay for results to display here? simpel post get javascript //post GET var http_request = false; function makeRequest(url, parameters) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { // set type accordingly to anticipated content type //http_request.overrideMimeType('text/xml'); http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('GET', url + parameters, true); http_request.send(null); document.getElementById('myspan').innerHTML = '<img src="images/loading.gif" alt="loding...">'; } function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { //alert(http_request.responseText); result = http_request.responseText; document.getElementById('myspan').innerHTML = result; } else { alert('error'); } } } function get(obj) { var getstr = "?"; for (i=0; i<obj.childNodes.length; i++) { if (obj.childNodes[i].tagName == "INPUT") { if (obj.childNodes[i].type == "text") { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } } } makeRequest('get.php', getstr); } Quote Link to comment https://forums.phpfreaks.com/topic/221124-onkeyup-delay/ Share on other sites More sharing options...
n3r0x Posted December 10, 2010 Share Posted December 10, 2010 Have a look at timers/settimeout on http://www.w3schools.com/js/js_timing.asp Quote Link to comment https://forums.phpfreaks.com/topic/221124-onkeyup-delay/#findComment-1145201 Share on other sites More sharing options...
tyra Posted December 13, 2010 Author Share Posted December 13, 2010 ok but where do i have to put this var t=setTimeout("alert('I am displayed after 3 seconds!')",3000); Quote Link to comment https://forums.phpfreaks.com/topic/221124-onkeyup-delay/#findComment-1146547 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.