Home Web Front-end JS Tutorial Discussion on the problem of obtaining the return value of another function from a function in js_javascript skills

Discussion on the problem of obtaining the return value of another function from a function in js_javascript skills

May 16, 2016 pm 05:13 PM
function return value

Copy code The code is as follows:

//This is asynchronous, and it doesn’t wait for ajax to finish assigning the value. The function returns.
function getCaseInfoForMap(){
var formInfo=$("#firstForm").serialize();
var dd;
$.ajax({
type:"post",
url:"<%=path %>/webmodule/constructionDecision/WjInfo/getCaseInfoForMap.do?timeType=" timeType "&gridNumber=" gridNumber,
dataType:"json",
data:formInfo,
success:function(data){
dd=data;
}
});
return dd;//
}
//Test
function test (){
var data=getCaseInfoForMap();
alert(data[0].caseId);
}

Copy code The code is as follows:

//This is synchronous async:false, ajax will not return until it is completed
function getCaseInfoForMap(){
var formInfo=$("#firstForm").serialize();
var dd="";
$.ajax({
type:"post",
url:"< ;%=path %>/webmodule/constructionDecision/WjInfo/getCommCaseInfoCount.do?timeType=" timeType "&gridNumber=110105217",
dataType:"json",
data:formInfo,
async:false ,
success:function(data){
dd=data;
}
});
return dd;
}
//Test
function test( ){
var data=getCaseInfoForMap();
alert(data);

}
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

From Zero to Mastery: Authoritative Interpretation of C++ Function Return Values From Zero to Mastery: Authoritative Interpretation of C++ Function Return Values Apr 30, 2024 am 10:24 AM

The return value type of a C++ function specifies the return value type after the function call, located after the function name and before the parentheses. The return value expression is an expression used to calculate and return the function value in the function body, usually placed in the return statement. Functions can also throw exceptions, and the type of exception thrown needs to be specified in the function declaration. Best practices for using function return values ​​include choosing an appropriate return type, clearly specifying the return type, setting exception types, and using explicit return statements.

Can golang variable parameters be used for function return values? Can golang variable parameters be used for function return values? Apr 29, 2024 am 11:33 AM

In Go language, variable parameters cannot be used as function return values ​​because the return value of the function must be of a fixed type. Variadics are of unspecified type and therefore cannot be used as return values.

What is the type of return value of Golang function? What is the type of return value of Golang function? Apr 13, 2024 pm 05:42 PM

Go functions can return multiple values ​​of different types. The return value type is specified in the function signature and returned through the return statement. For example, a function can return an integer and a string: funcgetDetails()(int,string). In practice, a function that calculates the area of ​​a circle can return the area and an optional error: funccircleArea(radiusfloat64)(float64,error). Note: If the function signature does not specify a type, a null value is returned; it is recommended to use a return statement with an explicit type declaration to improve readability.

How can the type of return value of a PHP function be determined? How can the type of return value of a PHP function be determined? Apr 15, 2024 pm 10:51 PM

Methods to determine the return value type of a PHP function include: 1. Using typehint declaration; 2. Inferring based on function definition; 3. Using gettype() function; 4. Using third-party libraries (such as Psalm and PHPStan).

Return value of C++ function: full analysis of type and meaning Return value of C++ function: full analysis of type and meaning Apr 30, 2024 am 10:21 AM

The return value type of a C++ function defines the result of the function call, which can be a basic type (such as int) or a user-defined type (such as a class). The meaning of the return value depends on the purpose of the function and can represent success/failure, operation results, or other information.

C++ function return value revealed: type interpretation and meaning analysis C++ function return value revealed: type interpretation and meaning analysis May 03, 2024 am 10:36 AM

The type of the C++ function return value specifies the data type returned and conveys the meaning of the function function. For example, a null value indicates that the function does not return any value. The success or failure status is expressed by an integer or Boolean. The specified result indicates the actual return value of the function operation. . Common return value types include built-in types (integers, decimals, etc.), pointer types (pointing to memory locations), reference types (aliases of variables or objects), and class types (user-defined data types). Through practical cases (summation function, email address verification function), we understood the application of different return value types in different functions.

What does function return value mean? What does function return value mean? Sep 22, 2023 am 11:55 AM

Function return value refers to the result returned after the function completes execution. The return value can be any data type, including integers, floating point numbers, characters, strings, Boolean values, etc. The function return value is used to pass the execution results of the function to other parts for further calculation, judgment, output and other operations. By returning the calculation results of the function to the caller, different parts of the program can be decoupled and the maintainability and readability of the code can be improved. When using function return values, you need to pay attention to the type and value range of the return value.

Detailed explanation of JavaScript function return values ​​and return statements Detailed explanation of JavaScript function return values ​​and return statements Aug 04, 2022 am 09:46 AM

JavaScript functions provide two interfaces to interact with the outside world. The parameters serve as the entrance to receive external information; the return value serves as the outlet to feed back the operation results to the outside world. The following article will take you to understand the JavaScript function return value and briefly analyze the usage of the return statement. I hope it will be helpful to you!

See all articles