XmlRpcRequest and XmlRpcResponse USE mimic

来源:互联网 发布:夏夏的淘宝店铺 编辑:程序博客网 时间:2024/06/16 11:34

 




Introduction

Mimicis an open source XML-RPC client implemented in JavaScript. It wasclassified as client, because it is only able to produce requests andparse responses, so you cannot use it to parse requests and produceresponses as required for a server implementation.

Itis intended to be embedded inside web pages and enable them to accessweb services based on XML-RPC through the W3C XMLHttpRequest interface.

It is compliant with the major browsers (IE, Firefox, Opera, Safari and Chrome).

 

源:http://mimic-xmlrpc.sourceforge.net/

 

How to Use

Itis very simple to use Mimic, you only have to produce a request andthen process the response. To do it you only have to use two smallclasses XmlRpcRequest and XmlRpcResponse.

Bellow we show a very simple example of a calculator accessed from Mimic:

 

The code used to access this service is:

 

view plainprint?
  1. function callCalculator() {  
  2.    var method = document.getElementById("operation").value;  
  3.    var request = new XmlRpcRequest("demos/calc.php", method);  
  4.    request.addParam(document.getElementById("n1").value);  
  5.    request.addParam(document.getElementById("n2").value);  
  6.    var response = request.send();  
  7.    alert(response.parseXML());  

原创粉丝点击