如何在Sartaj PHP中使用Ajax

I am new on this platform, How to use Ajax on this platform. Please explain it by using an example. Actually I have already used Ajax on core PHP, but here this platform is best for developing, and I am getting stuck with some problems. So please provide me solution about it.

In SartajPHP Framework you can setup AJAX by 3 way ..

  1. PSP Application:- If you are developing PSP Application then it will automatically create AJAX environment. This Example post txtName value to server on keyup event and server write response in divOutput..

type into mypspapp.psp file.

<codebehind  use_sjs_file="true"></codebehind>
<input id="txtName" type="text" runat="server" />
<div id="divOutput"></div>

type into mypspapp.php file.

<?php
class mypspapp extends \Sphp\tools\WebApp{
    public function sphp_txtName_keyup($param) {
        $this->JSServer->addJSONBlock('html','divOutput','Server Response you type:- ' . $this->Client->request("name"));
    }
}
?>

type into mypspapp.sjs file.

function ofjs_txtName_keyup(eventer){
    // Read txtName Value and post to server
    // insert code into real ofjs_txtName_keyup function
    data['name'] = $("#txtName").val();
}
  1. In Web Application:-

type into mypspapp.app file.

public function page_new(){
    $this->JSServer->getAJAX();
}
public function page_event_event1($param){
        $this->JSServer->addJSONBlock('html','divOutput','Server Response you type:- ' . $this->Client->request("name"));

}

type into mypspapp-form1.front file.

<input id="txtName" type="text" runat="server" onkeyup="var data = {}; data['name'] = $(this).val(); getURL('##{ getEventPath('event1') }#', data);" />
<div id="divOutput"></div>
  1. Use Form Control:- You can post form control via AJAX.

type into mypspapp-form1.front file.

<form id="form2" runat="server" funsetAJAX="">
<input id="txtName" type="text" runat="server" />
</from>
<div id="divOutput"></div>

type into mypspapp.app file.

public function onstart(){
    $this->temp1 = new TempFile($this->apppath . "forms/mypspapp-form1.front");
}
public function page_event_event1($param){
        $this->JSServer->addJSONBlock('html','divOutput','Server Response you type:- ' . $this->temp1->getComponenet("txtName")->getValue());

}
  1. Use Normal Ajax Call:- you can also send request via XMLHttpRequest or any other method. just change in Application $JSServer to echo...