title: $.ajax success function
body: <p>I have 3 files:</p>
  
  <p><strong>f1.php</strong></p>
  
  <pre><code>&lt;?php
   echo 'dis';
  ?&gt;
  </code></pre>
  
  <p><strong>f2.js</strong></p>
  
  <pre><code> $.ajax({
    url: "scripts/f1.php",
    success: function (rsp){
  
     // if its not exist
     if(rsp == "dis"){
      $("#sbmt_a").attr("disabled", "disabled"); //Disable Button
      //return = true;
     }
      else{
       $("#sbmt_a").removeAttr("disabled");
       // return = false;
      }
    }
   })
  </code></pre>
  
  <p><strong>p1.php</strong></p>
  
  <pre><code>//include f2.js - this is removed. code from f2.js is added at the bottom just before &lt;/body&gt;
  &lt;body&gt;
  &lt;form&gt;
  ...
  &lt;button id="sbmt_a" name="sbmt_a" class="eee"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  
  $(document).ready(function(){
       $.ajax({
    url: "scripts/f1.php",
    success: function (rsp){
  
     // if its not exist
     if(rsp == "dis"){
      $("#sbmt_a").attr("disabled", "disabled"); //Disable Button
      //return = true;
     }
      else{
       $("#sbmt_a").removeAttr("disabled");
       // return = false;
      }
    }
   })
  });
  &lt;/body&gt;
  </code></pre>
  
  <p>Now if I add in my js file something like <code>form.submit(function(){</code> I can use the <code>$.ajax</code> code and do whatever I like.</p>
  
  <p><strong>But</strong> is there a way to run the <code>$.ajax</code> code <strong>when someone visits my page?</strong> I mean when my page loads/reloads and the echo in f1.php is "dis" the form button becomes disabled.</p>