Although it is not a scientific calculator, it is the most advanced ajax calculator powered by an Ajax Framework, most just do simple addition of 2 numbers.
This is just an example of what you can do with the Cjax Framework.
Examples
PHP
<?php
$buttons = array(0,1,2,3,4,5,6,7,8,9,'p','m','x','c','e','d');
do {
$button = current($buttons);
$ajax->click("button{$button}", $ajax->call("ajax.php?calc/math/{$button}/|buffer|"));
} while($buttons && next($buttons));
?>
Controller
PHP
<?php
class Calc {
function math($action, $buffer)
{
$ajax = ajax();
$operators_signs = array('[plus]','p','m','x','d');
$operators = array('p','+','-','*','/');
$pre_buffer = $buffer;
$buffer = $ajax->buffer = $buffer.$action;
$buffer = str_replace($operators_signs, $operators, $buffer);
switch($action) {
case 'm'://minus
case 'p'://plus
case 'd'://divide
case 'x'://times
break;
case 'c': //clear
$ajax->buffer = null;
$ajax->result = null;
break;
case '=': //equal
$buffer = rtrim($buffer,"=+-\/*");
eval("\$action = ({$buffer});");
$ajax->result = $action;
$ajax->buffer = $action;
break;
default: //number
//get previous operator used, if not then keep putting numbers together
$prev = rtrim($pre_buffer, $action);
$prev = preg_replace("/[0-9]/", '', $prev);
if(!in_array($prev, $operators_signs)) {
$action = $buffer;
} else {
$action = preg_replace("/.+[^0-9]/", '', $buffer);
}
$ajax->result = $action;
}
}
}
?>