Documentation Index

CPAINT :: Cross-Platform Asynchronous INterface Toolkit

Developer's Guide : Backend

Backend Guide: Pages

introduction
integrating CPAINT
implementation differences
generating XML
complex return-data
arbitrary character encodings

Integrating the CPAINT Backend Classes

The first thing you must do is include the CPAINT backend in all the files that you want to make available to the frontend. Here are the backend file names, based on the language you are using:

ASP: cpaint2.inc.asp

Secondly, we must create an instance of the CPAINT backend class, start it, and return the results. We recommend you do this at the beginning of the file. Our code now looks similar to the following:

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) {
    return($sales_amount * 0.075);
  }
?>

For security reasons every one of your functions that should be callable by CPAINT must be published using the cpaint.register() method.

Because the whole point behind AJAX is to return XML from the backend, we have included helper methods in the CPAINT backend to help you generate proper XML. Although we are only returning a single value from this function, it's probably good practice to get used to using XML in case you write functions in the future that return multiple values.

That said, it's now time to modify our functions so that we can return the data to the frontend. There are some minor differences between each language, because they work differently.