新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
WCF實現(xiàn)loading功能正確方法
WCF開發(fā)工具是一個功能強大的由微軟公司開發(fā)的.NET Framework 3.5的重要組成部分。它的應(yīng)用可以幫助我們實現(xiàn)一個可靠性的開發(fā)框架。在這里我們先來為大家介紹一下WCF實現(xiàn)loading功能的相關(guān)操作。

創(chuàng)新互聯(lián)是一家專業(yè)提供任丘企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè)、H5技術(shù)、小程序制作等業(yè)務(wù)。10年已為任丘眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站建設(shè)公司優(yōu)惠進行中。
WCF實現(xiàn)loading功能步驟1.建立WCF project
默認的方法改為
- public string GetData(int value)
- {
- System.Threading.Thread.Sleep(5000); //模擬等待
- return string.Format("You entered: {0}", value);
- }
就加一句
- System.Threading.Thread.Sleep(5000); //模擬等待2.加入MCF/MCF.aspx VIEW
- < %@ Page Title="" Language="C#" MasterPageFile=
"~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>- < asp:Content ID="Content1" ContentPlaceHolderID=
"TitleContent" runat="server">- WCF
- < /asp:Content>
- < asp:Content ID="Content2" ContentPlaceHolderID="MainContent"
runat="server">- < script src="http://www.cnblogs.com/Scripts/jquery-1.3.2.js"
type="text/javascript">< /script>- < script language="javascript" type="text/javascript">
- $(function() {
- });
- < /script>
- < h2>
- WCF< /h2>
- < %using (Html.BeginForm())
- { %>
- < div id="divResult">
- < h3>
- Result< /h3>
- < fieldset>
- < div id="divLoading">
- < img src='< %=Url.Content("~/Content/images/loader.gif")%>'
alt="load" />- please waiting...< /div>
- < div id="DivResultData">
- < /div>
- < /fieldset>
- < /div>
- < %} %>
- < /asp:Content>3.寫Action,WCFController.cs
- public class WCFController : Controller
- {
- //
- // GET: /WCF/
- public ActionResult WCF()
- {
- return View();
- }
- [AcceptVerbs(HttpVerbs.Get)]
- public ActionResult WCFTest()
- {
- string strResult=string.Empty;
- WCFTest.Service1 testClient = new WCFTest.Service1();
- strResult = testClient.GetData(1);
- return Json(strResult);
- }
- }
WCF實現(xiàn)loading功能步驟2.編寫等待的loading..效果
- $(function() {
- $.ajax({
- type: "get",
- url: "WCFTest",
- datatype: "Json",
- data: "",
- complete: function() {
- $("#divLoading").css("display", "none");
- },
- success: function(data) {
- $("#DivResultData").html(data);
- }
- });
- });
WCF實現(xiàn)loading功能步驟3.調(diào)用WCF
- public ActionResult WCFTest()
- {
- string strResult=string.Empty;
- WCFTest.Service1 testClient = new WCFTest.Service1();
- strResult = testClient.GetData(1);
- return Json(strResult);
- }
以上就是對WCF實現(xiàn)loading功能的相關(guān)介紹。
網(wǎng)站欄目:WCF實現(xiàn)loading功能正確方法
標題來源:http://m.5511xx.com/article/dpeecio.html


咨詢
建站咨詢
