Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Need help with javascript and data from web service

Need help with javascript and data from web service

Scheduled Pinned Locked Moved JavaScript
questionjavajavascripttoolshelp
3 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CrafterIt
    wrote on last edited by
    #1

    Hi! I’m not so familiar with java script, i got the call to the web service working but how do i store the value from the web service in var result?, HelloWorld will be replaced with another method that returns different data depending on the input.

    <script type="text/javascript">
        $(document).ready(function () {	        
                var result;
                HelloWorld();
                // How do if store the data in result before the next line of code is executed?             
                
                //doSomething with the result
        });
    
        $(document).ready(function () {
               var result2;
               HelloWorld();
               // How do if store the data in result2 before the next line of code is executed?               
               
               // doSomething with the result
        });    
    
        function HelloWorld() {
            Pagesettings.test(HelloWorldCallback);         
        }
    
        function HelloWorldCallback(result) {
            alert(result);
        }
    
    </script>
    

    Can someone help me, thanks!

    M 1 Reply Last reply
    0
    • C CrafterIt

      Hi! I’m not so familiar with java script, i got the call to the web service working but how do i store the value from the web service in var result?, HelloWorld will be replaced with another method that returns different data depending on the input.

      <script type="text/javascript">
          $(document).ready(function () {	        
                  var result;
                  HelloWorld();
                  // How do if store the data in result before the next line of code is executed?             
                  
                  //doSomething with the result
          });
      
          $(document).ready(function () {
                 var result2;
                 HelloWorld();
                 // How do if store the data in result2 before the next line of code is executed?               
                 
                 // doSomething with the result
          });    
      
          function HelloWorld() {
              Pagesettings.test(HelloWorldCallback);         
          }
      
          function HelloWorldCallback(result) {
              alert(result);
          }
      
      </script>
      

      Can someone help me, thanks!

      M Offline
      M Offline
      Monjurul Habib
      wrote on last edited by
      #2

      Include jquery first then follow:

      <script type="text/javascript">   
       $(document).ready(function () {	
        PageMethods.MyMethod(HelloWorldCallback);
      });   
      function HelloWorldCallback(result) {
              alert(result);
          }
      </script>
      

      .cs file

      [WebMethod]
      public static string MyMethod()
      {

          return "Hello ";
      }
      
      C 1 Reply Last reply
      0
      • M Monjurul Habib

        Include jquery first then follow:

        <script type="text/javascript">   
         $(document).ready(function () {	
          PageMethods.MyMethod(HelloWorldCallback);
        });   
        function HelloWorldCallback(result) {
                alert(result);
            }
        </script>
        

        .cs file

        [WebMethod]
        public static string MyMethod()
        {

            return "Hello ";
        }
        
        C Offline
        C Offline
        CrafterIt
        wrote on last edited by
        #3

        Thanks, i will try this.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups