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 ..
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();
}
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>
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());
}