新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
WCF初試,用JQuery實(shí)現(xiàn)loading的功能
1.建立WCF project
[[3561]]

目前創(chuàng)新互聯(lián)已為成百上千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、網(wǎng)站托管、服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計、睢陽網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
默認(rèn)的方法改為
- 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>
- WCF h2>
- <%using (Html.BeginForm())
- { %>
- < div id="divResult">
- 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);
- }
- }
3.編寫等待的JQuery實(shí)現(xiàn)loading..效果
- $(function() {
- $.ajax({
- type: "get",
- url: "WCFTest",
- datatype: "Json",
- data: "",
- complete: function() {
- $("#divLoading").css("display", "none");
- },
- success: function(data) {
- $("#DivResultData").html(data);
- }
- });
- });
4.調(diào)用WCF
- public ActionResult WCFTest()
- {
- string strResult=string.Empty;
- WCFTest.Service1 testClient = new WCFTest.Service1();
- strResult = testClient.GetData(1);
- return Json(strResult);
- }
我不明白為什么我一把reference加入就可以使用WCF了,我看見網(wǎng)上很多文章很煩的要改一些東西啊,加一些代碼啊,請達(dá)人解釋
5.JQuery實(shí)現(xiàn)loading結(jié)果
[[3562]]
[[3563]]
網(wǎng)站題目:WCF初試,用JQuery實(shí)現(xiàn)loading的功能
當(dāng)前網(wǎng)址:http://m.fisionsoft.com.cn/article/djiesso.html


咨詢
建站咨詢
