Loading php file and then run function
<p>I am trying to pass some parameters to a php file and then load it on my page. After I do that I need to run a function. My problem is that jQuery runs the function before it loads the php file. I can get it working by adding a delay to my function using </p>

<pre><code>    setTimeout(function() {
        addSet(id);
    }, 500);
</code></pre>

<p>Instead I want it to run when my load function is done running. I have tried using $('#exer'+id).ready(function() { with no luck.</p>

<p>This is my code</p>

<pre><code>function addExercise(id, name, type, factor, desc) {
        $("&lt;div id='exer"+id+"' class='exer'&gt;lala&lt;/div&gt;").insertAfter("#beforeExercises");
        var php_file = "modules/ExerciseSearchTest2/addExercise.php?id="+ id + "&amp;name=" + name + "&amp;type=" + type + "&amp;factor=" + factor + "&amp;desc=" + desc;
        $("#exer"+id).load(encodeURI(php_file));

        addSet(id);
}
</code></pre>
