How to use AJAX framework dojo on Domino

Source: Internet
Author: User

As a Domino developer, the development of browser applications is an important part of this. However, there are many new techniques and methods in browser application development. How to apply these new technologies and methods to the domino environment is an important issue that domino developers need to face.

At present, we are in the era of Web 2.0, in this great era, there is a large number of browser technology, which is representative of Ajax. With Ajax, we can allow clients to exchange data with the server without refreshing the page, thereby generating a truly dynamic Web page. The use of Ajax includes some low-level coding, in order to simplify this work, people put forward the concept of Ajax framework, the AJAX-related low-level coding encapsulation, assembled into a simple and easy-to-use team. And Dojo is one of the most excellent Ajax frameworks.

This article does not describe Ajax and dojo in detail, please refer to the relevant resources for the specific content of Ajax and dojo. At the same time, this article will not introduce the Domino design method in detail, the reader needs to have some experience in domino development. This article is mainly about how to use the Dojo framework in a Domino environment and combine dojo with Domino's design elements.

Ajax and Dojo Introduction

The English full name of Ajax is: Asynchronous JavaScript and XML, Chinese meaning "Asynchronous JavaScript and XML". Where JavaScript is used for foreground processing, XML is used for foreground and background data transfer. It is called "asynchronous" because Ajax uses an asynchronous way to interact with the server, and after the current processing of JavaScript sends out a data request to the background, the program control right is returned to JavaScript. When the server responds to requests in the background, JavaScript in the foreground can continue to run and perform other actions. When the server side finishes processing the request and returns the result, the previously specified method is triggered in the foreground to process the returned results.

This asynchronous communication capability that Ajax has has benefited from a new JavaScript object at the lower level: XMLHttpRequest. Its core function is to send an HTTP request to the specified server and specify a JavaScript method as the callback function. When this HTTP request is sent, the current page does not need to be refreshed. At the same time, although the specified callback function waits for the server to process the result, the foreground JavaScript can continue to work and respond to other user actions in the foreground.

With Ajax technology, developers need to create XMLHttpRequest objects and implement callback functions. If you implement such details on every page element that you need, there is a lot of work to do and the code is not easy to manage. In this case, people put forward the concept of Ajax framework, through the AJAX technology to achieve a large number of practical small components, developers only need to invoke the widget can be asynchronous interaction with the server.

In the Ajax framework, Dojo is one of the most excellent. Dojo is an open source project, although on Dojo's home page, they just define dojo as an Open-source DHTML project, but it's certainly a framework for maximizing Ajax advantage.

Implement the most basic Ajax calls on Domino

Because Domino is a complete HTTP server, developers can implement Ajax calls in the Domino environment by writing code without adding other frameworks, enabling complex asynchronous applications. To keep readers focused on the key to implementing Ajax calls on Domino, here's the simplest example to illustrate.

First, to test the need, we set up a test database on the test server, called: Ajaxsample.nsf. Then, create a form in the database named: Sampleajax. In addition, in the same database create a page named Samplepage, which input text "testing page" as content. We will implement Ajax calls in the form Sampleajax to dynamically get the contents of the page "Samplepage" without refreshing the current page.

Enter the following code in the "JS Header" event in the form Sampleajax:

Listing 1. Ajax calls code that returns data

var oXHR;
function mycallback() {
 if (oXHR.readyState == 4) {
   if (oXHR.status == 200) {
    alert(oXHR.responseText);
   } else {
    alert('error');
   }
 }
}

Then create a button and an editable text field in the form that triggers the Ajax call, and the editable text field is used to prove whether the current page is refreshed. The results of the above steps are shown in the following illustration:

Figure 1. Created scripts, buttons, and text fields

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.