Regular polling request, the client uses Ajax to tune the WebService method

Source: Internet
Author: User

Server Release WebService, the box must have

Client code

<script type= "Text/javascript" > $ (document). Ready (function () {getwebservice ();        SetInterval (Getwebservice, 1000);        });        var Swic = true;        var count = 1; function Getwebservice () {//Call no parameter method $.ajax ({type: "POST", Contenttyp E: "Application/json;charset=utf-8",//webservice will return the JSON type URL: "Http://localhost:3933/WebService/Interfac Eservice.asmx/helloworld ", Data:" {} ",//email parameter dataType: ' JSON ', success:f                    Unction (Result) {var text = "Get Request" +count+ "Times:" +result.d.tostring () + ""; $ ("#txtContent"). Text (text) if (SWIC) {$ ("#txtContent"). attr ("style", "Color:re                        D ");                    Swic = false;                        } else {$ ("#txtContent"). attr ("style", "Color:blue"); Swic =True                } count++;                    }, Error:function (R, S, e) {debugger;                     callback handling when the request fails.                Alert (e);        }            }); } </script>

  

<asp:content id= "bodycontent" runat= "Server" contentplaceholderid= "maincontent" >    

Front page display

Regular polling request, the client uses Ajax to tune the WebService method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.