Using ajax calls we have the ability to perform actions after it hase run using the done()-function
$.ajax({ ..... }) .done ( function(data) { ..... (manipulate data using $.ajax result }) Right now I have an if-else clause with an ajax-embedded in it.
if (some condition) { //Standard HTML-element/tag manipulation $("#obj1").append('<a class="trigger">Click Me </trigger>'); $(".SomeClass").remove(); ...... } else { //HTML-element/tag manipulation after $.ajax-call $.ajax({ //perform ajax-call }) .done(function (data) { $("#obj1").append('<a class="trigger">' data.someProp '</trigger>'); }) } //Perform actions: Part2 $(".trigger").Click(function() { Somefunction() }); I was wondering if Jquery offers a way to make the execution of the functions in Part2 halt until all actions inside the if-else are completed (including the $.ajax)?. I can't seem to find anything around this using google (most likely i'm just using the wrong keywords).
I hope my question is understandable for everyone. If you need further information, don't hesitate to comment.
part2inside a function and call that from theifbranch and from thedonefunction in theelsebranch?