Requirement: A, b two tasks are processed (whether a, B is successful or failed), and the following tasks are performed.
Code Listing 1:
Java code
- var leftresult = Leftpromise.then (
- function (value) {
- Console.info ("Jsona End");
- }, function () {
- Console.info ("Jsona fail");
- }
- );
- var rightresult = Rightpromise.then (
- function (value) {
- Console.info ("jsonb End");
- }, function () {
- $ ("#jsonB"). Val ("");
- Console.info ("jsonb fail");
- }
- );
- $.when (Leftresult, Rightresult). Always (
- function () {
- Console.info ("Start compare");
- });
You may be able to perform the following tasks directly after the a task fails.
The When method is defined as any failure, or all success is executed down. What do we do?
Through a always-on packaging solution:
Java code
- var leftresult = Leftpromise.then (
- function (value) {
- Console.info ("Jsona End");
- }, function () {
- Console.info ("Jsona fail");
- }
- ). Always (
- function () {
- Console.info ("Jsona always");
- var d = $. Deferred ();
- D.resolve ();
- return d.promise ();
- }
- );
- var rightresult = Rightpromise.then (
- function (value) {
- Console.info ("jsonb End");
- }, function () {
- $ ("#jsonB"). Val ("");
- Console.info ("jsonb fail");
- }
- ). Always (
- function () {
- Console.info ("jsonb always");
- var d = $. Deferred ();
- D.resolve ();
- return d.promise ();
- }
- );
- $.when (Leftresult, Rightresult). Always (
- function () {
- Console.info ("Start compare");
- });
The point here is that after then there is a Always,always method that returns must be successful, allowing the When method to satisfy the conditions that are successfully executed down.
_-html Tutorial-html Tutorial
A brief introduction to _-html tutorial-html of the Perak Ape tutorial
The _-html tutorial-html basics of the Perak Ape tutorial
Break Ape Tutorial _-html tutorial-html elements
Perak Ape Tutorial _-html Tutorial-html Properties
Break Ape Tutorial _-html tutorial-html Title
Break Ape Tutorial _-html Tutorial-html Paragraph
Break Ape Tutorial _-html Tutorial-html Links
Break Ape Tutorial _-html tutorial-html Head
Perak Ape Tutorial _-html tutorial-html CSS
Break Ape Tutorial _-html Tutorial-html image
The strain on the When method of jquery