title: Sharing AJAX call with JQuery
body: <p>I have an input field. When the page is loaded, if input is pre-populated, then make AJAX call. Otherwise, wait until input field change to make AJAX call.</p>
  
  <p>My AJAX call is quite complicated, so I want these two scenarios to share the same function.</p>
  
  <p>Here is my implementation (pseudo code):</p>
  
  <pre><code> function checkInput { $.ajax(... complex logic goes here ...); }
  
    $(document).ready(function() {
      if (!!$("#input").val()) {
        checkInput();    
      }
    });
  
    $("#input").change(checkInput());
  </code></pre>
  
  <p>Problem is, the function checkInput is invoked right away. </p>
  
  <p>How can I avoid this problem?</p>
  
  <p>Thank you.</p>