Calling a Javascript function after AJAX call
<p>I have a javascript function to which I am being passed a functionName that I need to call after making a ajax call. The ajax call is returning some html that contains a reference to a js file. The functionName being passed to my funtion is in the html but it is referencing an object in the js file. What I am noticing that the object sometimes exists and sometimes doesnt. Is there a way to ensure that the object always exists(or wait till it exists) and then only call the javascript function. Please note that I have no idea what the object variable is, so is there a way to ensure that the script file has been loaded in dom and then make the call to the function.</p>

<pre><code>   function(functionName)
   {
      $.ajax({
    url: properties.url,
    type: properties.type,
    data: properties.data,
    dataType: properties.format,
    success: function (data) {
     // data contains &lt;div&gt;myname&lt;/div&gt;&lt;script src="/myfile.js" type="text/javascript"&gt;&lt;/script&gt;
     // Put the data in some div
     BindData(data);

     // How to ensure that the script myfile.js is loaded in dom before I call eval
     eval(functionName);
     }   );      

    }
</code></pre>
