Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript progress of xml http request

<!DOCTYPE html>
<html>
<body>
<p id="demo">result</p>
<button type="button" onclick="get_post_ajax();">Change Content</button>
<script type="text/javascript">
	function update_progress(e)
	{
	  if (e.lengthComputable)
	  {
	    var percentage = Math.round((e.loaded/e.total)*100);
	    console.log("percent " + percentage + '%' );
	  }
	  else 
	  {
	  	console.log("Unable to compute progress information since the total size is unknown");
	  }
	}
	function transfer_complete(e){console.log("The transfer is complete.");}
	function transfer_failed(e){console.log("An error occurred while transferring the file.");}
	function transfer_canceled(e){console.log("The transfer has been canceled by the user.");}
	function get_post_ajax()
	{
	  	var xhttp;
	  	if (window.XMLHttpRequest){xhttp = new XMLHttpRequest();}//code for modern browsers} 
	 	else{xhttp = new ActiveXObject("Microsoft.XMLHTTP");}// code for IE6, IE5	  	
	  	xhttp.onprogress = update_progress;
		xhttp.addEventListener("load", transfer_complete, false);
		xhttp.addEventListener("error", transfer_failed, false);
		xhttp.addEventListener("abort", transfer_canceled, false);	  	
	  	xhttp.onreadystatechange = function()
	  	{
	    	if (xhttp.readyState == 4 && xhttp.status == 200)
	    	{
	      		document.getElementById("demo").innerHTML = xhttp.responseText;
	    	}
	  	};
	  xhttp.open("GET", "http://it-tu.com/ajax_test.php", true);
	  xhttp.send();
	}
</script>
</body>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: select selected option value jquery 
Javascript :: No provider for ReducerManager 
Javascript :: react add class to each children 
Javascript :: Next js window is not defined solution 
Javascript :: log odd numbers js 
Javascript :: cart page url in shopify 
Javascript :: how to minimize electron app to tray icon 
Javascript :: js array from 
Javascript :: variable for every user discord.js 
Javascript :: namespace in javascript 
Javascript :: duplicate elements of array multiple times 
Javascript :: how to remove property from object javascript 
Javascript :: reactjs node sass incompatible with ^4.0.0 ^5.0.0 
Javascript :: react native safeareaview 
Javascript :: javascript array.find 
Javascript :: text.toUpperCase is not a function 
Javascript :: angular automatic typewriter animation 
Javascript :: filter repetition multidimensional array javascript 
Javascript :: django ajax body to json 
Javascript :: js subarray 
Javascript :: remove element from array by name javascript 
Javascript :: clear interval js 
Javascript :: reverse array without using another array js 
Javascript :: find my url in nodejs 
Javascript :: typescript interface with unknown keys 
Javascript :: javascript auto scroll on bottom 
Javascript :: get background image url jquery 
Javascript :: mongoose return only a certain number of results 
Javascript :: angular loop through key values in map 
Javascript :: angular 8 filter array of objects by property 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =