News
IBM to offer mobile security as a service IBM will start delivering mobile security-as-a-service (MaaS) through its own cloud infrastructure in India, a move that is expected to better address in-country data requirements... IBM Spectrum Computing: IBM has enlarged its portfolio of software-defined infrastructure solutions with cognitive features for workload management.  * LiFi internet technology has been introduced, the new type of wireless internet connection that gives 100 times faster than traditional WiFi -- Invented by Professor Harald Haas from the University of Edinburgh. * Sci. Rachid Yazami has developed a smart chip that charges smartphones in less than 10 minutes. BenQ has launched BlueCore projector - Consumer electronics major BenQ has launched its first BlueCore laser light source projector. For those unaware, devices with BlueCore laser technology have a high contrast output of 80000:1 with an extended lamp life and efficiency. ***
  Feb 27 2016 11:51AM     John
  2 Comments    752 Views  
Here John provided a short example for Webservice call from client side. ie., jQuery

Here, I gave simple example to call webservice webmethod from HTML page using jQuery.

The example shows, to get the content from webservice in every 1 minute. 

Use of setTimeout()

Copy the code and paste it in your script file.

        $(document).ready(function () {

            //ReloadPage();
            setTimeout("ReloadPage()", 10000);
        });

        function ReloadPage() {
            var profileID = 10;
            CallWebMethod(profileID);
            setTimeout("ReloadPage()", 10000);
        };

Ajax to call Webmethod with Parameter:


            function CallWebMethod(id) {

            $.ajax({
                type: "POST",
                url: "http://192.158.2.175/WebService/ws/dataservice.asmx/GetProfileDataByID",
                data: "{'profileID' : " + id + "}",
                dataType: 'json',
                contentType: 'application/json; charset=utf-8',
                async: true,
                success: function (data) {

                    var responseJson = JSON.parse(JSON.stringify(data.d));
                    alert(responseJson );
                },
                error: function (e) {

                    alert(e.responseText);
                }
            });
        }


Ajax to call Webmethod without Parameter:


            function CallWebMethod() {

            $.ajax({
                type: "POST",
                url: "http://192.158.2.175/WebService/ws/dataservice.asmx/GetAllProfileData",
                data: {},
                dataType: 'json',
                contentType: 'application/json; charset=utf-8',
                async: true,
                success: function (data) {

                    var responseJson = JSON.parse(JSON.stringify(data.d));
                    alert(responseJson );
                },
                error: function (e) {

                    alert(e.responseText);
                }
            });
        }


Here, I have showed simple example for webservice call from javascript. Hope it helps for you. Thanks
BackToTop
Comments


Zz Lorreta
May 4 2016 6:59PM
rasteredge can provide youc# add comments to pdf reader, and download it to try it free on rasteredge page http://www.rasteredge.com/how-to/csharp-imaging/pdf-html5-feature-annotate/
AnonymousUser
Mar 20 2017 9:54AM
I seriously love your site.. Excellent colors

 
Search
1&1 Hosting
Recent Posts
Bind Gridview from CSV file in Asp.Net C#
Jun 18 2016 11:38PM Posted By Michael
Call WebService method from jQuery in every 1 minute
Feb 27 2016 11:51AM Posted By John
Gridview custom CSS in ASP.Net
Feb 25 2016 10:59AM Posted By Micheal Ryan
Read excel file and bind to Gridview in C#
Feb 25 2016 10:20AM Posted By Micheal
Read excel file and convert to List in C#
Feb 25 2016 6:26AM Posted By Michael
Encryption and Decryption for Password in C#
Feb 17 2016 3:52AM Posted By Michael
How to create Chart in ASP.Net C#
Feb 16 2016 8:03AM Posted By Michael Ryan
Tags
Follow us on Facebook
Follow us on Google +
Recent post in your Email inbox.
Enter your email address: