php教程 php手册 Xajax手册(第一版)

Xajax手册(第一版)

Jun 21, 2016 am 09:07 AM
javascript nbsp the

ajax

原文:http://xajax.sourceforge.net/
英文原版:Copyright © 2005 J. Max Wilson
简体中文翻译:HonestQiao(乔楚)/2005-12-7 17:23/(第一版)
什么是xajax?
xajax如何工作?
为什么我要使用xajax代替其他PHP的Ajax库?
如何在我的PHP脚本之中使用xajax?
如何异步更新内容?
如何异步处理表单数据?
如何给xajax增加定制功能?
我能在私有或者收费产品之中使用xajax吗?
 
What is xajax?
How does xajax work?
Why should I use xajax instead of another Ajax library for PHP?
How do I use xajax in my PHP script?
How do I update my content asynchronously?
How do I process form data asynchronously?
How do I add custom functionality to xajax?
May I use xajax in a proprietary product and charge for it?
什么是xajax?
Xajax是一个开源的 PHP 类库 它能够让你黏合HTML、CSS、JavaScript和PHP,轻而易举的开发功能强大、基于WEB的AJAX应用软件. 使用xajax开发的应用软件,无需重新调入页面,就能够异步调用服务器端的PHP函数和更新内容.
What is xajax?
xajax is an open source PHP class library that allows you to easily create powerful, web-based, Ajax applications using HTML, CSS, JavaScript, and PHP. Applications developed with xajax can asynchronously call server-side PHP functions and update content without reloading the page.
 
xajax 如何工作?
你的应用软件需要异步调用的PHP函数, xajax的PHP对象都生成了对应的封装好了的JavaScript函数. 当被调用时,封装的函数使用JavaScript的XMLHttpRequest对象与服务器异步通讯,调用xajax对象对应的PHP函数. 调用结束后, PHP函数由xajax返回一个xajax的XML响应传递给应用程序. XML响应包含了特定的指令和数据,他们可以被xajax的JavaScript消息分析器解析,并且被用于更新你的应用程序的内容.
How does xajax work?
The xajax PHP object generates JavaScript wrapper functions for the PHP functions you want to be able to call asynchronously from your application. When called, these wrapper functions use JavaScript's XMLHttpRequest object to asynchronously communicate with the xajax object on the server which calls the corresponding PHP functions. Upon completion, an xajax XML response is returned from the PHP functions, which xajax passes back to the application. The XML response contains instructions and data that are parsed by xajax's JavaScript message pump and used to update the content of your application.
为什么我要使用xajax代替其他PHP的ajax库?
你应该选择一个最是和你的项目需要的库.
xajax 提供了以下的功能, 它们使得ajax富有特色而又功能强大:
Why should I use xajax instead of another Ajax library for PHP?
You should choose whatever library will best meet the needs of your project.
xajax offers the following features that, together, make it unique and powerful:
Xajax特殊的 XML 响应 / javascript 消息分析系统 帮助你做到, 自动的处理函数返回的数据,按照PHP函数返回的指令更新内容或者状态. 因为xajax作了这些工作Because xajax does the work, 你不需要写javascript的回调处理函数.
xajax's unique XML response / javascript message-pump system does the work for you, automatically handling the data returned from your functions and updating your content or state according to the instructions you return from your PHP functions. Because xajax does the work, you don't have to write javascript callback handler functions.
Xajax反对将代码和数据紧密地杂糅在一起的主张, 并且保持xajax的代码从与他代码分离. 因为它是对象构造的, 你可以加上自己定制的功能给xajax去扩展xajaxResponse 类和使用addScript方法.
xajax is object oriented to maintain tighter relationships between the code and data, and to keep the xajax code separate from other code. Because it is object oriented, you can add your own custom functionality to xajax by extending the xajaxResponse class and using the addScript() method.
xajax 可以工作在 Firefox, Mozilla, 大部分基于 Mozilla 的浏览器, Internet Explorer, 和 Safari.
xajax works in Firefox, Mozilla, probably other Mozilla based browsers, Internet Explorer, and Safari.
除了更新元素的值和内含的HTML内容(innerHTML), xajax 还能用于更新样式(styles), css 类, 多选和单选按钮选择,甚至可以更新任何元素的属性.
In addition to updating element values and innerHTML, xajax can be used to update styles, css classes, checkbox and radio button selection, or nearly any other element attribute.
xajax 支持使用一维或者多维数组、关联数组(哈希数组) 作为xajax函数的参数从javascript传送给PHP. 反之Additionally, 如果你传送一个javascript的对象给xajax函数,PHP函数将接受一个描叙对象属性的关联数组(哈希数组).
xajax supports passing single and multidimensional arrays and associative arrays from javascript to PHP as parameters to your xajax functions. Additionally, if you pass a javascript object into an xajax function, the PHP function will receive an associative array representing the properties of the object.
xajax 提供了一种简单的异步表单处理方式. 使用 xajax.getFormValues() javascript 方法, 你可以轻而易举的在表单之中提交一个描绘值的数组作为参数传送到xajax异步处理函数:
xajax_processForm(xajax.getFormValues('formId');
. 它可以处理复杂的input 元素名称 ,例如 "checkbox[][]" 或者 "name[first]" 产生的多维或者关联数组(哈希数组), 就是普通提交表单那样使用PHP的$_GET数组
xajax provides easy asynchronous Form processing. By using the xajax.getFormValues() javascript method, you can easily submit an array representing the values in a form as a parameter to a xajax asynchronous function:
xajax_processForm(xajax.getFormValues('formId');
. It even works with complex input names like "checkbox[][]" and "name[first]" to produce multidimensional and associative arrays, just as if you had submitted the form and used the PHP $_GET array
使用xajax你可以动态的发送附加的javascript作为请求的响应到你的应用软件中运行,而这就和动态的更新元素的属性一样方便.
Using xajax you can dynamically send additional javascript to your application to be run in response to a request as well as dynamically update element attributes.
Xajax会自动比较PHP函数返回的数据与你已经标记需要修改的元素属性. 只有当新的数据确实可以改变现有的属性,属性才会真的被更新. 这将可消除程序在一定时间间隔内更新与当前内容相同或者不同的内容而出现的明显的闪烁.
xajax automatically compares the data returned from the PHP functions to the data that is already in the attribute of the element you have marked for change. The attribute is only updated with the new data if it will actually change what is already in the attribute. This eliminates the flicker often observed in applications that update content at a regular time interval with data which may or may not differ from extant content.
每一个通过xajax简单注册的函数都可以有不同的请求方式. 所有的函数默认使用POST方式,除非你明确的指定使用GET方式. 如果使用GET请求,你必须非常明确的考虑它确实是你所需要的
Each function registered to be accessible through xajax can have a different request type. All functions default to use POST unless GET is explicitly set. This is to encourage careful consideration of when to use GET requests
如果没有指定URI,xajax将设法自动确定脚本的URI. Xajax的自动确定算法经过了充分的验证,确保在大部分HTTPS或者未知端口的HTTP服务器上也可以正常的工作.
If no request URI is specified, xajax tries to autodetect the URL of the script. The xajax autodetection algorithm is sophisticated enough that, on most servers, it will work under a secure https:// protocol as well as http:// and with nonstandard ports.
Xajax使用UTF8编码所有的请求和响应,以确保支持绝大部分的字符和语言. Xajax已经成功测试了多种不同的UNICODE字符,包括Spanish, Russian, Arabic, and Hebrew
xajax encodes all of its requests and responses in UTF-8 so that it can support a wider range of characters and languages. xajax has been successfully tested with various unicode characters including Spanish, Russian, Arabic, and Hebrew
几乎所有xajax生成的javascript都可以通过动态的外部javascript包含到你的web程序之中. 当你在浏览器之中查看程序的源代码时,不会有JavaScript的函数定义混杂在HTML标记之中.
Nearly all of the javascript generated by xajax is included into your web application through dynamic external javascript. When you view the source of your application in your browser, the markup will be not cluttered by JavaScript function definitions.
Xajax可以使用在Smarty模板系统之中,仅仅需要创建一个smarty变量就可以包含xajax的javascript:
$smarty->assign('xajax_javascript', $xajax->getJavascript());
然后你可以使用在header模版之中使用
{$xajax_javascript}
从而把xajax应用到你的站点.
xajax can be used with the Smarty templating system by creating a variable in smarty that contains the xajax javascript:
$smarty->assign('xajax_javascript', $xajax->getJavascript());
Then you can use
{$xajax_javascript}
in your header template to use xajax on your site.
如何在我的PHP脚本之中使用xajax?
Xajax的设计是如此的富有特色,以至于不管是已有的web程序还是新的项目,它都能够被极其简单的部署和应用. 仅仅需要七步,你就可以在几乎任何PHP脚本之中加入xajax的强大功能:
How do I use xajax in my PHP script?
xajax is designed to be extremely easy to implement in both existing web applications as well as new projects. You can add the power of xajax to nearly any PHP script in seven easy steps:
包含xajax类库:
require_once("xajax.inc.php");
实例化xajax 对象:
$xajax = new xajax();
注册你需要通过xajax调用的PHP函数的名称:
$xajax->registerFunction("myFunction");
编写注册的PHP函数,并且在函数之中使用xajaxResponse 对象返回XML指令:
function myFunction($arg)
{
   // 对$arg做一些基本处理例如从数据库检索数据
   // 然后把结果赋值给变量,例如$newContent
  
   // 实例化xajaxResponse 对象
   $objResponse = new xajaxResponse();
  
   // 添加指令到响应之中,用于指派
   //指定元素(例如id="SomeElementId")的innerHTML属性的新的内容
   $objResponse->addAssign("SomeElementId","innerHTML", $newContent);
  
   //返回xajaxResponse 对象生成的XML响应
   return $objResponse->getXML();
}
在你的脚本输出任何信息之前,调用xajax用于接管请求:
$xajax->processRequests();
在页面的 标签之间, 告诉xajax生成所必需的JavaScript:
printJavascript(); ?>
在程序中,从JavaScript事件或者函数调用前面注册的函数:


  // Instantiate the xajaxResponse object
  $objResponse = new xajaxResponse();

  // add a command to the response to assign the innerHTML attribute of
  // the element with id="SomeElementId" to whatever the new content is
  $objResponse->addAssign("SomeElementId","innerHTML", $newContent);

  //return the XML response generated by the xajaxResponse object
  return $objResponse->getXML();
}
Before your script sends any output, have xajax handle any requests:
$xajax->processRequests();
Between your tags, tell xajax to generate the necessary JavaScript:
printJavascript(); ?>
Call the function from a JavaScript event or function in your application:




본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Windows 11에서 밝기를 조정하는 10가지 방법 Windows 11에서 밝기를 조정하는 10가지 방법 Dec 18, 2023 pm 02:21 PM

화면 밝기는 최신 컴퓨팅 장치를 사용할 때 필수적인 부분이며, 특히 화면을 장시간 볼 때 더욱 그렇습니다. 눈의 피로를 줄이고, 가독성을 높이며, 콘텐츠를 쉽고 효율적으로 보는 데 도움이 됩니다. 그러나 설정에 따라 밝기 관리가 어려울 수 있으며, 특히 새로운 UI 변경이 적용된 Windows 11에서는 더욱 그렇습니다. 밝기를 조정하는 데 문제가 있는 경우 Windows 11에서 밝기를 관리하는 모든 방법은 다음과 같습니다. Windows 11에서 밝기를 변경하는 방법 [10가지 설명] 단일 모니터 사용자는 다음 방법을 사용하여 Windows 11에서 밝기를 조정할 수 있습니다. 여기에는 단일 모니터를 사용하는 데스크탑 시스템과 노트북이 포함됩니다. 시작하자. 방법 1: 알림 센터 사용 알림 센터에 액세스할 수 있습니다.

Safari에서 iPhone의 개인 브라우징 인증을 끄는 방법은 무엇입니까? Safari에서 iPhone의 개인 브라우징 인증을 끄는 방법은 무엇입니까? Nov 29, 2023 pm 11:21 PM

iOS 17에서 Apple은 모바일 운영 체제에 몇 가지 새로운 개인 정보 보호 및 보안 기능을 도입했습니다. 그 중 하나는 Safari의 개인 탐색 탭에 대해 2단계 인증을 요구하는 기능입니다. 작동 방식과 끄는 방법은 다음과 같습니다. iOS 17 또는 iPadOS 17을 실행하는 iPhone 또는 iPad에서 Safari에 개인 정보 보호 브라우징 탭이 열려 있는 경우 이제 Apple 브라우저에 Face ID/Touch ID 인증이나 암호가 필요하며, 다시 액세스하려면 세션이나 앱을 종료해야 합니다. 즉, 잠금이 해제된 iPhone이나 iPad를 다른 사람이 손에 넣는 경우에도 비밀번호를 모르면 개인정보를 볼 수 없습니다.

WebSocket과 JavaScript를 사용하여 온라인 음성 인식 시스템을 구현하는 방법 WebSocket과 JavaScript를 사용하여 온라인 음성 인식 시스템을 구현하는 방법 Dec 17, 2023 pm 02:54 PM

WebSocket 및 JavaScript를 사용하여 온라인 음성 인식 시스템을 구현하는 방법 소개: 지속적인 기술 개발로 음성 인식 기술은 인공 지능 분야의 중요한 부분이 되었습니다. WebSocket과 JavaScript를 기반으로 한 온라인 음성 인식 시스템은 낮은 대기 시간, 실시간, 크로스 플랫폼이라는 특징을 갖고 있으며 널리 사용되는 솔루션이 되었습니다. 이 기사에서는 WebSocket과 JavaScript를 사용하여 온라인 음성 인식 시스템을 구현하는 방법을 소개합니다.

2개월 만에 휴머노이드 로봇 '워커S' 옷 개기 가능 2개월 만에 휴머노이드 로봇 '워커S' 옷 개기 가능 Apr 03, 2024 am 08:01 AM

기계력 보고서 편집자: 우신(Wu Xin) 국내판 휴머노이드 로봇+대형 모델팀이 옷 접기 등 복잡하고 유연한 재료의 작업 작업을 처음으로 완료했습니다. OpenAI 멀티모달 대형 모델을 접목한 Figure01이 공개되면서 국내 동종업체들의 관련 진전이 주목받고 있다. 바로 어제, 중국의 "1위 휴머노이드 로봇 주식"인 UBTECH는 Baidu Wenxin의 대형 모델과 긴밀하게 통합되어 몇 가지 흥미로운 새로운 기능을 보여주는 휴머노이드 로봇 WalkerS의 첫 번째 데모를 출시했습니다. 이제 Baidu Wenxin의 대형 모델 역량을 활용한 WalkerS의 모습은 이렇습니다. Figure01과 마찬가지로 WalkerS는 움직이지 않고 책상 뒤에 서서 일련의 작업을 완료합니다. 인간의 명령을 따르고 옷을 접을 수 있습니다.

WebSocket 및 JavaScript: 실시간 모니터링 시스템 구현을 위한 핵심 기술 WebSocket 및 JavaScript: 실시간 모니터링 시스템 구현을 위한 핵심 기술 Dec 17, 2023 pm 05:30 PM

WebSocket과 JavaScript: 실시간 모니터링 시스템 구현을 위한 핵심 기술 서론: 인터넷 기술의 급속한 발전과 함께 실시간 모니터링 시스템이 다양한 분야에서 널리 활용되고 있다. 실시간 모니터링을 구현하는 핵심 기술 중 하나는 WebSocket과 JavaScript의 조합입니다. 이 기사에서는 실시간 모니터링 시스템에서 WebSocket 및 JavaScript의 적용을 소개하고 코드 예제를 제공하며 구현 원칙을 자세히 설명합니다. 1. 웹소켓 기술

WebSocket과 JavaScript를 사용하여 온라인 예약 시스템을 구현하는 방법 WebSocket과 JavaScript를 사용하여 온라인 예약 시스템을 구현하는 방법 Dec 17, 2023 am 09:39 AM

WebSocket과 JavaScript를 사용하여 온라인 예약 시스템을 구현하는 방법 오늘날의 디지털 시대에는 점점 더 많은 기업과 서비스에서 온라인 예약 기능을 제공해야 합니다. 효율적인 실시간 온라인 예약 시스템을 구현하는 것이 중요합니다. 이 기사에서는 WebSocket과 JavaScript를 사용하여 온라인 예약 시스템을 구현하는 방법을 소개하고 구체적인 코드 예제를 제공합니다. 1. WebSocket이란 무엇입니까? WebSocket은 단일 TCP 연결의 전이중 방식입니다.

JavaScript 및 WebSocket을 사용하여 실시간 온라인 주문 시스템을 구현하는 방법 JavaScript 및 WebSocket을 사용하여 실시간 온라인 주문 시스템을 구현하는 방법 Dec 17, 2023 pm 12:09 PM

JavaScript 및 WebSocket을 사용하여 실시간 온라인 주문 시스템을 구현하는 방법 소개: 인터넷의 대중화와 기술의 발전으로 점점 더 많은 레스토랑에서 온라인 주문 서비스를 제공하기 시작했습니다. 실시간 온라인 주문 시스템을 구현하기 위해 JavaScript 및 WebSocket 기술을 사용할 수 있습니다. WebSocket은 TCP 프로토콜을 기반으로 하는 전이중 통신 프로토콜로 클라이언트와 서버 간의 실시간 양방향 통신을 실현할 수 있습니다. 실시간 온라인 주문 시스템에서는 사용자가 요리를 선택하고 주문을 하면

JavaScript와 WebSocket: 효율적인 실시간 일기예보 시스템 구축 JavaScript와 WebSocket: 효율적인 실시간 일기예보 시스템 구축 Dec 17, 2023 pm 05:13 PM

JavaScript 및 WebSocket: 효율적인 실시간 일기 예보 시스템 구축 소개: 오늘날 일기 예보의 정확성은 일상 생활과 의사 결정에 매우 중요합니다. 기술이 발전함에 따라 우리는 날씨 데이터를 실시간으로 획득함으로써 보다 정확하고 신뢰할 수 있는 일기예보를 제공할 수 있습니다. 이 기사에서는 JavaScript 및 WebSocket 기술을 사용하여 효율적인 실시간 일기 예보 시스템을 구축하는 방법을 알아봅니다. 이 문서에서는 특정 코드 예제를 통해 구현 프로세스를 보여줍니다. 우리

See all articles