<script language="javascript" type="text/javascript"> $.ready(function BtnSpareClick() { $.ajax({ type: "get", url: "http://www.jb51.net/windy2008/rss", data: {}, global: false, beforeSend: function(data, status, settings) { $("#Process").text("Part請求開始前"); alert($("#Process").text()); }, success: function(data, status, settings) { $("item", data).each(function(i, domEle) { $("#Result").append("<div>" + $(domEle).children("title").text() + "</div>"); }); $("#Process").text("Part請求成功時"); alert($("#Process").text()); }, complete: function(data, status, settings) { $("#Process").text("Part請求完成時"); alert($("#Process").text()); }, error: function(data, status, settings) { $("#Process").text("Part請求錯誤時"); alert($("#Process").text()); } }); }); </script> |
<script language="javascript" type="text/javascript"> $.ready(function BtnGlobalClick() { $.get("http://www.jb51.net/windy2008/rss", {}, function(data, status, settings) { $("item", data).each(function(i, domEle) { $("#Result").append("<div>" + $(domEle).children("title").text() + "</div>"); }); }); $("#Process").ajaxStart(function() { alert($(this).text()); $(this).text("開始新的Ajax請求"); }); $("#Process").ajaxStop(function() { $(this).text("當沒有Ajax進行中中的時候"); alert($(this).text()); }); $("#Process").ajaxSend(function() { $(this).text("請求開始前"); alert($(this).text()); }); $("#Process").ajaxSuccess(function() { $(this).text("請求成功"); alert($(this).text()); }); $("#Process").ajaxComplete(function() { $(this).text("請求完成時"); alert($(this).text()); }); $("#Process").ajaxError(function() { $(this).text("請求錯誤時"); alert($(this).text()); }); }); </script> |