Commits

illume committed 583c29d

updated example html to work a little better.

Comments (0)

Files changed (1)

js/example/index.html

 <script type="text/javascript" src="jquery.js"></script>
 <script type="text/javascript">
 	// Check if we have been processed server side or not.
-	if(typeof window._processedServerSide === undefined) {
+	if(typeof window._processedServerSide === "undefined") {
 		// We should be client side, so fetch the json.
 		// Note, you can skip the json loading if you do not need to use json.
-		var clientJSON = 'client.json';
-
-		$.getJSON(clientJSON, function(data) {
-			// When processed on the server side window._jsonData 
-			//     is put there by the server.
-			window._jsonData = data;
-		});
-
+		var clientJSON = 'server.json';
 		var loadScript = function (url) {
 			document.write('<' + 'script src="', url, '" type="text/javascript"' + '><' + '/' + 'script' + '>');
 		}
+
+		//synchronous get the json, so it is included here, and not later.
+		// This way the server side stuff is called before the client side stuff.
+		// Which more closely emulates what happens when it is rendered on the server.
+		$.ajax({
+			type: 'GET',
+			url: clientJSON,
+			dataType: 'json',
+			success: function(data) { 
+				// When processed on the server side window._jsonData 
+				//     is put there by the server.
+				window._jsonData = data;
+			},
+			data: {},
+			async: false
+		});
+
 		// Your server side scripts get run on client side if not processed on server side.
-		loadScript('yourServerSide.js');
-		loadScript('yourServerSide2.js');
+		loadScript('js/yourServerSide.js');
+		loadScript('js/yourServerSide2.js');
 	}
 </script>
 
 
 
+
 <!-- Load your non-server side stuff afterwards.  -->
 <script type="text/javascript">
 	$(document).ready(function(){