title: Get return value from Controller to javascript
body: <p>What I want is, I want to check whether there is a file in the database or not. To do this I have a method in the controller which checks this and returns a boolean for the corresponding case. It looks like this:  </p>
  
  <pre><code>public bool fileInDb(int empId)
      {
          using (SLADbContext db = new SLADbContext())
          {
              bool file = db.CompetenceUploads.Any(x =&gt; x.EmployeeId == empId);
              if (file)
              {
                  return true;
              }
              else
              {
                  return false;
              }
          }
      }  
  </code></pre>
  
  <p>I simply just check if there is any file assigned to the given employee.  </p>
  
  <p>Now I would like to call this method from my javascript in the view, and get the return value, so that I can let the user know, if there is a file assigned to the selected employee or not. It may look like this:  </p>
  
  <pre><code>$("#get-file").click(function() {
  
          empId: $("#EmployeeSelect").val();
          var fileInDb = // Get the return value from the method 'fileInDb'
  
          if(fileInDb) {
              // Let the user download the file he/she requested
              var url = "@Url.Action("GetUploadedFile", "Competence")";
              this.href = url + '?empId=' + encodeURIComponent($("#EmployeeSelect").val());
          } else {
              alert("There is no file assigned to this employee.");
          }
      });  
  </code></pre>
  
  <p>So my question now is, how do I get the get the return value from the method in the controller?  </p>