Home > Web Front-end > JS Tutorial > body text

ext synchronous and asynchronous sample code_extjs

WBOY
Release: 2016-05-16 18:45:58
Original
1329 people have browsed it

There are fewer documents related to synchronous calls. The following is a synchronization example, that is, when the page is loaded, or when this js is called, the program will go down line by line, which is used for some functions such as obtaining data or styles required for page initialization.
Sample code:

Copy code The code is as follows:

//Determine button permissions method. true means no permission, false means permission can be displayed
function checkButton(buttonId){

//The status of the button, ext has higher requirements on types, so pay attention to the conversion of types and variables.
var state = new Boolean(true);

//What is called here is the synchronous method of ext, which should be distinguished from the asynchronous call
var conn = Ext.lib.Ajax.getConnectionObject ().conn;
//The second parameter is the address requested from the background. The output data of the requested background method is: conn.responseText data
    conn.open("get", '/base/business /SysPublicAction.do?operate=checkButtonsState&buttonId=' buttonId,false);
conn.send(null);
//conn.responseText is a string type
//The string cannot be assigned to state. So here we can only judge the characters to change the state
if(conn.responseText=="false")
state = new Boolean(false);

return state.valueOf();
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!