You must Sign In to post a response.
  • Category: JavaScript

    How to write xml in java script

    How can we write a xml string and assing values to the node in xml string in javascript
    and also how to call a web service from java script paasing a input parameter
  • #756684
    Hai Shilpa,
    To call web-service using JavaScript, you can use the JQuery Ajax call and pass the parameters required in forms of the Data section.
    You need to use ScriptReference and ServiceReference tags under the ScriptManager and then define the path of the Web Service and then you can call the web methods.
    In the ServiceReference, we need to define the service path where the actual service exists.
    So if you only want to use the JavaScript, then also you can use the below code snippet:

    <asp:ScriptManager runat="server" ID="sm">
    <Scripts>
    <asp:ScriptReference Path="MyScripts.js" />
    </Scripts>
    <Services>
    <asp:ServiceReference Path="MyWebService.asmx" />
    </Services>
    </asp:ScriptManager>

    Now once you define the service and scripts, you can directly call the webmethods as:

    <button id="clickMe" onclick="GetMe()">ClickMe</button>

    You can also go to the below link where you can find the other work around to use the callback methods, methods with the parameters etc.:

    https://www.asp.net/ajax/documentation/live/tutorials/ConsumingWebServicesWithAJAXTutorial.aspx

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


  • Sign In to post your comments