Jump to content
Gerhard

New data only when debugger on

Recommended Posts

Hi,

 

have now a running version of a script. Does get data correct from server, but only once.

Repeat hitting 'View' button doesnt produce new data requests (checked this by having a breakpoint on my servers C# code). After pressing F12 and invoking the debugger within IE11, each hit of 'View' sends a request to the server.

Any idea?

 

Script in the attachment.

 

With best regards

 

Gerhard

JsonViewer.html

Share this post


Link to post
Share on other sites

i used your script + some miner changes ,i used the json from http://www.w3schools.com/appml/customers.php .made some change to listJson function .

 

using IE 8 i replaced document.getElementById("demo").innerHTML = text; by $('#demo').html(text); and it works .

 

heres the script :

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="dcterms.created" content="Di, 29 Dez 2015 22:56:32 GMT">
    <meta name="description" content="GeoMon Template Page">
    <meta name="keywords" content="Just a template">
	  <meta content="text/html; charset=utf-8" http-equiv="content-type" />
  	<meta name="viewport" content="width=device-width, initial-scale=1">
  	<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  	<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <title>Json Viewer</title>
  </head>
<body>

<p>The best way to loop through an array is using a standard for loop:</p>

<button onClick="readFromServer('http://www.w3schools.com/appml/customers.php')">Try it</button>

<p id="demo"></p>

<script>
function listJson( content )
	{
	  var index, text = "<ul>";
		for (index = 0; index < content.records.length; index++)
		text += "<li>" + content.records[index].CustomerName + "  " + content.records[index].City + "</li>";
    text += "</ul>";
    $('#demo').html(text);
	//document.getElementById("demo").innerHTML = text;
	}
  function readFromServer(url)
		{
			var xmlhttp = new XMLHttpRequest();
      xmlhttp.onreadystatechange = 
				      function() 
							  { 
				          if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
						  {
						   document.getElementById("demo").innerHTML = "";
						   setTimeout(function(){  listJson(JSON.parse(xmlhttp.responseText)); }, 3000);
						    	
						  } 
				        };
       xmlhttp.open("GET", url, true);
       xmlhttp.send();
		 }
		 
	
</script>

</body>
</html>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...