How to call a webservice method from an html page [javascript] with out refresh the page

后端 未结 2 1557
不知归路
不知归路 2021-02-02 01:01

I have a webservice which will return a value. Here my requirement is, I need to call that webservice from an index.html page, that page h

2条回答
  •  既然无缘
    2021-02-02 01:43

    Use jQuery for performin POST or GET request from your html page like this :

    function fun() 
    {
       var data="hello";
       $.get("http://localhost/ws/service.asmx/HelloWord", function(response) {
            data = response;
       }).error(function(){
      alert("Sorry could not proceed");
    });
    
       return data;
    }
    

    OR :

    function fun() 
    {
      var data="hello";
      $.post('http://localhost/ws/service.asmx/HelloWord',{},function(response) 
      {     data = response;
      }).error(function(){
      alert("Sorry could not proceed");
    });
    
        return data;
    }
    

提交回复
热议问题