Topic: how to access form values
I'm very new to xajax and found this forum very helpful to far. However, I can't seem to get any data from a form.
I dumbed both code and smary template down to a bare minimum and all I could get from alert(print_r($_POST,true));
is an array:
Array
(
[xjxfun] => processdata
[xjxr] => 1258982310134
)
code:
<?php
include('./smartystuff.php');
$smarty->force_compile=1;
$smarty->caching=0;
function processdata($data)
{
$objResponse=new xajaxResponse();
$objResponse->alert(print_r($_POST,true));
return $objResponse;
}
require_once("xajax/xajax_core/xajax.inc.php");
$xajax = new xajax();
$xajax->configure('javascript URI', 'xajax/');
$xajax->register(XAJAX_FUNCTION, "processdata");
$smarty->assign("xajax_javascript", $xajax->getJavascript());
$xajax->processRequest();
$xajax->configure('debug', true);
$smarty->display('test.tpl.php');
?>
test.tpl.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home Page</title>
{$xajax_javascript}
</head>
<body>
<h2>Data:</h2>
<form name="company_data" id="company_data" method="POST" onsubmit="xajax_processdata(xajax.getFormValues('company_data'); return false;">
Companyname: <input type="text" class="text" id="companyname" name="companyname" value=""><br/>
<input type="button" name="submit" value="verstuur" class="button" onclick="xajax_processdata();">
</form>
</body>
</html>
Versions:
Smarty 2.6.26
PHP 5.2.1
Xajax 0.5
Any help would be greatly appriciated as I'm quite sure I'm overlooking the obvious here.