title: mvc 3 razor call a server side function using jquery
body: <p>i'm using this code to get a partial view from the server ot put it in a div</p>
  
  <pre><code>    $.ajax(
      {
          type: "POST",
          url: "MyControler/MyAction",
          success: function (result) {
              $('#partialView').html(result);      
          },
          error: function (req, status, error) {
              alert("Coudn't load partial view");
          }
      });
  </code></pre>
  
  <p>now i would like to do the same thing but i'd call a simple methode returning a string and put the result in a textbox</p>
  
  <pre><code>    $.ajax(
      {
          type: "POST",
          url: "MyControler/MyMethod",
          success: function (result) {
              $('#myTextBox').html(result);      
          },
          error: function (req, status, error) {
              alert("Coudn't load partial view");
          }
      });
  </code></pre>
  
  <p>the methode would be like that</p>
  
  <pre><code>    public string MyMethod()
      {
          returning "hello";
      }
  </code></pre>
  
  <p>obviously it doesn't work but is there a way to make it work ?? is there an attribute i should use for the methode </p>
  
  <p>thanks in advance</p>
  
  <p>ps:</p>
  
  <p>from what i red in the first answer i tried this but it doesn't work </p>
  
  <pre><code>    public ActionResult Hello()
      {
          return Content("Hi there!");
      }
  </code></pre>
  
  <p>is there something wrong with the ajax call ??</p>
  
  <pre><code>$.ajax(
      {
          type: "POST",
           url: "MyControler/Hello",
          success: function (result) {
              $('#myTextBox').html(result);      
       },
      error: function (req, status, error) {
          alert("Coudn't load partial view");
      }
  });
  </code></pre>
  
  <p>ps</p>
  
  <p>I wanted to try on a clean project and it worked fine using a simple method returning a string</p>
  
  <p>since it worked i tried to implement it to my project but it seems it only works from the starting page set up in the global.asax file any idea what i should do to make it work in every pages ??? </p>