title: call c# logic from external javascript file
body: <p>I'm very new in javascript, I have a problem, I have a external js file which I need to run some c# server side codes. my external js file is something like:</p>
  
  <pre><code>my.login = function(parameter, callback) {
      if(someCondition)
      {
          alert("you cant progress")
      }
      else
      {
          //not importent logic
      }
  }
  </code></pre>
  
  <p>I considered two ways for preparing some condition one of them with ajax call:</p>
  
  <pre><code>$.get("locallhost:2756/myCont/MyAct?Id=" + Id + "", function(response) {
      if (!response.result) {
          alert("you cant progress");
      }
  </code></pre>
  
  <p>but I get the error $ is not defined
  another option is using XmlHttpRequest like this:</p>
  
  <pre><code>var xhReq = new XMLHttpRequest();
  xhReq.open("POST", "locallhost:2756/myCont/MyAct?Id=" + Id + "", true);
  xhReq.send(Id);
  var res = xhReq.response;
  var stat= XMLHttpRequest.status;
  var resText= xhReq.responseText;
  </code></pre>
  
  <p>but I get nothing in resText its "",
  My controller and action are also like this:</p>
  
  <pre><code>public class myContController : Controller
  {      
  
      [HttpPost]
      public JsonResult MyAct(string Id)
      {
          if (Logic.ValidateId(Id))
          {
              return Json(new { result = true });
          };
          return Json(new { result = false });
      }
  }
  </code></pre>
  
  <p>all I want is validate something in c# and return the result if it's ok or not to javascript, If there is another way, would you please help me?</p>
  
  <p>EDIT:
  I know I can reference jquery in html files to avoid $ not defined but this is external js that others can use it which they are not in my projects. I need to do something with that external js</p>