Commits

Greg Slepak  committed 8001ff9

fixed broken dragonfly_ajax-twitter and improved ajax-updater

  • Participants
  • Parent commits f2213b7

Comments (0)

Files changed (3)

File example-site/dragonfly-framework/plugins-active/dragonfly_basic.lsp

 		<div id="%s">&nbsp;</div>
 		<script type="text/javascript">
 			(function fetcher() {
-				$.post("%s", "%s",
-					function (data, status) {
-						$("#%s").html(data);
+				var id = '#' + '%s';
+				var load_text = 'loading...';
+				setTimeout(function() {
+					if (load_text)
+						$(id).html(load_text);
+				}, 500);
+				$.ajax({
+					url: "%s",
+					data: "%s",
+					type: "POST",
+					timeout: 10000,
+					success: function (data, status) {
+						load_text = null;
+						$(id).html(data);
+						setTimeout(fetcher, %d);
+					},
+					error: function (xmlReq, status, error) {
+						load_text = null;
+						$(id).html(status + ' (' +  error + ') loading: ' + this.url);
 						setTimeout(fetcher, %d);
 					}
-				);
+				});
 			})();
 		</script>
-		[/text] html-elementid request-url str-params html-elementid timeout)
+		[/text] html-elementid html-elementid request-url str-params timeout timeout)
 	)
 )
 

File example-site/views/dragonfly_ajax-twitter.html

-<% (twitter-search "michael jackson" "1") %>
+<%
+(DF:activate-plugin "dragonfly_twitter")
+(twitter-search "michael jackson" "1")
+%>

File example-site/views/dragonfly_ajax.html

 		<h1>AJAX calls</h1>
 		<p class="extract">Dragonfly provides some simple AJAX functions. With AJAX, web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing page. The use of AJAX techniques has led to an increase in interactive or dynamic interfaces on web pages and better quality of Web services due to the asynchronous mode. Data is usually retrieved using the XMLHttpRequest object. (source: wikipedia.org)
 		</p>
-		<h2>Current time</h2>
+		<h2>Current server time</h2>
 		<% (ajax-updater "timer" "/dragonfly_ajax-date" "gettime" 1000) %>
 
 		<h2>Real-time tweets for 'michael jackson'</h2>