spacer
Yehuda Shiran November 22, 2001
Handling the result Object
Tips: November 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management
One of the two ways to call a Web service is with a callback handler. Here is an example that calls the add method with two arguments, intA and intB:

iCallID = service.MyMath.callService(mathResults,"add", intA, intB);
The event handler mathResults() accepts the result object as its sole parameter:

  function mathResults(result)
The name of the parameter can be different than "result". Inside, it checks whether there were errors during the call to the Web service:

  if (result.error) { .... }
Use this check to write an event handler that processes the result object and prints the error details (if any) as well as the result value. Here is a Microsoft example:

<SCRIPT language="JavaScript">
<!--
// All these variables must be global,
// because they are used in both init() and onResult().
var iCallID = 0;
var intA = 5;
var intB = 6;

function init() {
  service.useService("/services/math.asmx?WSDL","MyMath");
  iCallID = service.MyMath.callService(mathResults, "add", intA, intB);
}

function mathResults(result) {
  if(result.error) {
    var xfaultcode   = result.errorDetail.code;
    var xfaultstring = result.errorDetail.string;
    var xfaultsoap   = result.errorDetail.raw;
  } else{  
      alert(intA + ' + ' + intB + " = " + result.value);
    }
}
// -->
</SCRIPT>
<BODY onload="init()">
<DIV ID="service" style="behavior:url(webservice.htc)">
</DIV>
</HTML>

People who read this tip also read these tips:

Look for similar tips by subject:

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

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

webref The latest from WebReference.com Browse >
Administering MySQL Databases on the Web Using PHP · Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
So what is an Oracle Nested Table? · E-Discovery Architectures 101 · eBay Embraces Big Sellers, Cyber Monday Trends