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.
1条回答 默认 最新
- weixin_33688840 2017-11-30 22:53关注
In SartajPHP Framework you can setup AJAX by 3 way ..
- 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(); }
- 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>
- 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()); }
- Use Normal Ajax Call:- you can also send request via XMLHttpRequest or any other method. just change in Application $JSServer to echo...
解决 无用评论 打赏 举报
悬赏问题
- ¥15 宇视监控服务器无法登录
- ¥15 PADS Logic 原理图
- ¥15 PADS Logic 图标
- ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
- ¥20 气象站点数据求取中~
- ¥15 如何获取APP内弹出的网址链接
- ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
- ¥50 STM32单片机传感器读取错误
- ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
- ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)