自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

WCF初試,用JQuery實(shí)現(xiàn)loading的功能

開(kāi)發(fā) 開(kāi)發(fā)工具
今天想起接觸WCF(Windows Communiction Foundation),開(kāi)始弄個(gè)很小的例子。這里為大家講用JQuery實(shí)現(xiàn)loading的功能

1.建立WCF project

[[3561]]

默認(rèn)的方法改為

  1. public string GetData(int value)  
  2.         {  
  3.             System.Threading.Thread.Sleep(5000);    //模擬等待  
  4.             return string.Format("You entered: {0}", value);  
  5.         } 

就加一句

  System.Threading.Thread.Sleep(5000);    //模擬等待

2.加入MCF/MCF.aspx VIEW

  1. < %@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 
  2.  
  3. < asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> 
  4.     WCF  
  5. < /asp:Content> 
  6. < asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 
  7.  
  8.     < script src="http://www.cnblogs.com/Scripts/jquery-1.3.2.js" type="text/javascript">script> 
  9.  
  10.     < script language="javascript" type="text/javascript"> 
  11.         $(function() {  
  12.         });  
  13.     < /script> 
  14.  
  15.     <h2> 
  16.         WCFh2> 
  17.         <%using (Html.BeginForm())  
  18.           { %> 
  19.     < div id="divResult"> 
  20.         <h3> 
  21.             Resulth3> 
  22.         < fieldset> 
  23.             < div id="divLoading"> 
  24.                 < img src='<%=Url.Content("~/Content/images/loader.gif")%>' alt="load" /> 
  25.                 please waiting...div> 
  26.             < div id="DivResultData"> 
  27.             div> 
  28.         < /fieldset> 
  29.     < /div> 
  30.     <%} %> 
  31. < /asp:Content> 

3.寫Action,WCFController.cs

  1. public class WCFController : Controller  
  2.     {  
  3.         //  
  4.         // GET: /WCF/  
  5.         public ActionResult WCF()  
  6.         {  
  7.             return View();  
  8.         }  
  9.         [AcceptVerbs(HttpVerbs.Get)]  
  10.         public ActionResult WCFTest()  
  11.         {  
  12.             string strResult=string.Empty;  
  13.             WCFTest.Service1 testClient = new WCFTest.Service1();  
  14.             strResult = testClient.GetData(1);  
  15.             return Json(strResult);  
  16.         }  
  17.     } 

3.編寫等待的JQuery實(shí)現(xiàn)loading..效果

  1. $(function() {  
  2.           $.ajax({  
  3.               type: "get",  
  4.               url: "WCFTest",  
  5.               datatype: "Json",  
  6.               data: "",  
  7.               complete: function() {  
  8.                   $("#divLoading").css("display", "none");  
  9.               },  
  10.               success: function(data) {  
  11.                   $("#DivResultData").html(data);  
  12.               }  
  13.           });  
  14.       }); 

4.調(diào)用WCF

  1. public ActionResult WCFTest()  
  2.         {  
  3.             string strResult=string.Empty;  
  4.             WCFTest.Service1 testClient = new WCFTest.Service1();  
  5.             strResult = testClient.GetData(1);  
  6.             return Json(strResult);  
  7.         } 

我不明白為什么我一把reference加入就可以使用WCF了,我看見(jiàn)網(wǎng)上很多文章很煩的要改一些東西啊,加一些代碼啊,請(qǐng)達(dá)人解釋

5.JQuery實(shí)現(xiàn)loading結(jié)果

[[3562]]

 [[3563]]

【編輯推薦】

  1. jQuery調(diào)用WCF服務(wù)傳遞JSON對(duì)象
  2. 學(xué)習(xí)jQuery必須知道的幾種常用方法
  3. 用XML+XSLT+CSS+JQuery組建ASP.NET網(wǎng)站
  4. JQuery ID選擇器中的不能包含特殊字符的處理
  5. 使用jQuery和PHP構(gòu)建一個(gè)受Ajax驅(qū)動(dòng)的Web頁(yè)面
責(zé)任編輯:彭凡 來(lái)源: cnblogs
相關(guān)推薦

2010-02-22 14:28:35

WCF實(shí)現(xiàn)loadin

2010-02-25 13:35:27

WCF tcpTrac

2009-12-08 15:06:33

WCF傳輸DataSe

2022-02-17 14:34:10

viewport項(xiàng)目API

2012-04-20 10:05:16

WCF

2009-12-08 14:28:16

XTemplate +

2010-02-23 09:51:32

WCF MTOM

2009-11-09 16:25:24

WCF Data Co

2009-12-04 17:35:51

WCF 服務(wù)

2009-12-07 10:27:51

WCF分頁(yè)

2009-07-03 09:44:39

實(shí)現(xiàn)RSS功能JSP技術(shù)

2010-12-28 13:44:12

PHPXMLjQuery

2011-05-16 09:30:30

jQueryWCF

2009-06-12 14:32:53

WCFJSON對(duì)象jQuery

2009-09-11 10:44:07

JavaScript實(shí)

2010-02-26 10:56:06

WCF Stream

2010-02-22 17:13:40

WCF會(huì)話狀態(tài)

2010-02-25 16:12:23

WCF IDispos

2009-12-21 10:00:46

WCF基礎(chǔ)開(kāi)發(fā)

2012-12-28 14:32:34

Android開(kāi)發(fā)Handler異步處理
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)