class NameObj
{
// Name of object
private $name ;
/**
* Enter description here...
*
* @return NameObj
*/
public function NameObj()
{
$this->name = "username";
}
/**
* Enter description here...
*
* @return unknown
*/
public function GetName()
{
return $this->name;
}
/**
* Enter description here...
*
* @param unknown_type $newName
*/
public function SetName($newName)
{
$this->name = $newName ;
}
}
$newName = $_GET["name"] . "";
$nobj = new NameObj();
//$nobj->SetName($newName);
echo $nobj->GetName() ." chay phia Server";
?> <script language="javascript" type="text/javascript" >
// Ajax function
function XMLHttpClient() {
var xmlhttp;
try {
// Mozilla / Safari / IE7
xmlhttp = new XMLHttpRequest();
} catch (e) {
// IE
var XMLHTTP_IDS = new Array('MSXML2.XMLHTTP.5.0',
'MSXML2.XMLHTTP.4.0',
'MSXML2.XMLHTTP.3.0',
'MSXML2.XMLHTTP',
'Microsoft.XMLHTTP' );
var success = false;
for (var i=0;i < XMLHTTP_IDS.length && !success; i++) {
try {
xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]);
success = true;
} catch (e) {}
}
if (!success) {
throw new Error('Unable to create XMLHttpRequest.');
}
}
return xmlhttp;
}
function SetName(name)
{
var req =XMLHttpClient() ;
req.open('GET', 'SetName.php?name=Thu_Ajax', false);
req.send(null);
var newName =req.responseText;
alert(newName);
}