Please note: CPAINT nor this website is under active development. |
Developer's Guide : Backend
Backend Guide: Pages
introduction
integrating CPAINT
implementation differences
generating XML
complex return-data
arbitrary character encodings
Generating the XML
As mentioned above, we use XML by default to return data from the backend. Since we're only returning a single value, we can use the cpaint.set_data() method on the top level to set the data. Use this method in place of function return statements.
PHP Example
<?php
require_once("cpaint v2/cpaint.inc.php");
$cp = new cpaint():
$cp->register('calculate_tax');
$cp->start();
$cp->return_data();function calculate_tax($sales_amount) {
global $cp;
$cp->set_data($sales_amount * 0.075);
}
?>
For simple returns, we're now done. The XML that will be returned from the backend will look like (assuming the input value was 1):
<ajaxResponse>1.075</ajaxResponse>