Home > Web Front-end > JS Tutorial > Detailed explanation of the use of jQuery callback methods

Detailed explanation of the use of jQuery callback methods

小云云
Release: 2018-01-06 10:20:30
Original
2838 people have browsed it

This article mainly introduces the use of jQuery callback method, and analyzes the principle, definition and usage of jQuery callback method in the form of specific examples. Friends in need can refer to it. I hope it can help everyone.

The method parameter has a function method, and the calculated data is returned after execution.


function a1(p){ // p 为调用此方法传递的object对象
  var callback = p?p.callback:null; // 获取参数对象中的回调方法
  if($.isFunction(p.callback)){ // 如果有回调方法
    callback("123"); // 返回一个计算后的数据,方便回调方法使用它
  }
}
function a2(data){
  console.info(data);
}
// 调用a1方法
a1({callback:function(callbackData){ // 参数为一个object对象,其中key为callback的val是一个function方法,并且需要a1方法计算得到的值
  // a1方法执行完成之后 进入回调用法,接着调用a2方法
  a2(callbackData);
}});
Copy after login

In this way, after the a1 method is executed, the a1 method is obtained The calculated value is then passed to the a2 method for execution.

Related recommendations:

Reentrancy of ASP.NET timer callback method

PHP callback method_PHP tutorial

Implementation analysis of python callback function and callback method

The above is the detailed content of Detailed explanation of the use of jQuery callback methods. For more information, please follow other related articles on the PHP Chinese website!

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