WebServiceMultipleCallers.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // WebServiceMultipleCallers.js
  2. // This function calls a Web service method
  3. // passing simple type parameters and the user context.
  4. function AddWithContext(a, b, userContext)
  5. {
  6. Samples.AspNet.WebService.Add(a, b,
  7. SucceededCallbackWithContext, FailedCallback, userContext, null);
  8. }
  9. // This function calls the Web service method
  10. // passing the method name.
  11. function AddWithMethod(a, b)
  12. {
  13. Samples.AspNet.WebService.Add(a, b,
  14. SucceededCallbackWithContext, FailedCallback);
  15. }
  16. // This is the callback function called if the
  17. // Web service succeeded. It accepts the result
  18. // object, the user context, and the method name as
  19. // parameters.
  20. function SucceededCallbackWithContext(result, userContext, methodName)
  21. {
  22. // It holds feedback message.
  23. var output = "";
  24. // Page element to display the feedback message.
  25. var RsltElem =
  26. document.getElementById("Results");
  27. if (userContext)
  28. {
  29. output += "The user context is : " + userContext + "<br/>";
  30. RsltElem.innerHTML = output;
  31. return;
  32. }
  33. if (methodName)
  34. output += "The method name is : " + methodName + "<br/>";
  35. RsltElem.innerHTML = output;
  36. }
  37. // This is the callback function called if the
  38. // Web service failed. It accepts the error object
  39. // as a parameter.
  40. function FailedCallback(error)
  41. {
  42. // Display the error.
  43. var RsltElem =
  44. document.getElementById("Results");
  45. RsltElem.innerHTML =
  46. "Service Error: " + error.get_message();
  47. }
  48. if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();