title: can we call ajax method in else part of function?
body: <p>I know this is very basic question but</p>
  
  <p><strong>Is this a good practice although code works fine?</strong></p>
  
  <p>I'm working on mvc project and i just need to confirm wether it is a good practice to do this or not?</p>
  
  <p>code
  .cshtml</p>
  
  <pre><code>$(document).ready(function () {
      var serviceURL = '/AjaxTest/FirstAjax';
      if(serviceURL = null ) { alert ("BANG! error")}
      else {
          $.ajax({
                  type: "POST",
                  url: serviceURL,
                  data: param = "",
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  success: successFunc,
                  error: errorFunc
          });
      }
  }
  </code></pre>
  
  <p>please share your comments.</p>