spacer
Yehuda Shiran July 16, 2002
Displaying Web Service Results
Tips: July 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

When you want to consume your own Web services, put them (asmx files) in a sub-directory of your Web server, such as c:\inetpub\wwwroot\Webreference. Then, when you access the services in your scripts, you refer to their directory as http://localhost/Webreference. For each Web service you consume you need to have three JavaScript functions:

  • The init() function assigns a short name to the Web service URL
  • A function to call the Web service with the appropriate parameters
  • A function to display the results

We use DIV elements to display results of Web services. Once a result is ready, we update the innerHTML property of the appropriate element. Here is how we update the result of the add Web service:

  function addResult(result) {
    theResult1.innerHTML = result.value;
  }
We embed the result of the IsPrime Web service within a descriptive message:

  function isPrimeNumberResult(result) {
    theResult2.innerHTML = "The number " + testValue.value + 
      (result.value ? " is" : " is not") + " a prime number";
  }
To learn more about JScript .NET, go to Column 112, JScript .NET, Part VI: Creating IE Web Services.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint