title: Call JQuery function from a MVC Action
body: <p>I want to fire a <strong>Jquery function</strong> from my <strong>MVC Action code</strong>.
  Know that it isn't possible via the direct code, If anyone knows how to do this task via any kind of possible forms such as publishing an event or do that with using ajax call or whatever.</p>
  
  <p>Here I have a <strong>JQuery Plugin</strong> which can be run with the below code.</p>
  
  <pre><code>$('#myModal').Show();
  </code></pre>
  
  <p>their original calling mechanism was :</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
       $('#myButton').click(function(e) {
            e.preventDefault();
        $('#myModal').Show();
       });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>A little more explanation:</strong></p>
  
  <p>I don't want most of the code except the line I mentioned.
  Maybe here we should make it a more simple function before running the provided hack.
  We don't the button event-handler what we want is : after the Action in the Controller have <strong>sent an email</strong> call this function <code>$('#myModal').Show();</code></p>
  
  <p><strong>The Action :</strong></p>
  
  <pre><code>[HttpPost]
  public ActionResult Contact(Contact message)
  {
      if (ModelState.IsValid)
      {
          string stResult ;
          Emailing.SendEmail(message, out stResult);
          ViewBag.SaveResultMessage = stResult;
      }
      return View(message);
  }
  </code></pre>
  
  <p>Action is called from the Contact View :</p>
  
  <pre><code>    @Html.ValidationSummary(true)
      @using (Html.BeginForm("Contact", "Home", FormMethod.Post, new { name = "send-contact", 
                id = "contactform1"}))
      {           
              if (!String.IsNullOrEmpty(stResult)) 
               {   
                  // $('#myModal').Show(); I hoped we could do this way.
               }
          ...
       }
  </code></pre>
  
  <p>Any sample codes and demo on your provided solution is really appreciated.</p>
  
  <p><strong>Edit (Based on the bAlexandre answer):</strong></p>
  
  <p>your code :
          $("#btnSubmit").click(function () {
              // let's show a loading image
              //$(".myModal").Loading();  // We don't want the load or waiting operations,
              // Just want to show the final message such as "Successful !" to the user.
              // I don't think yet it be right but after got sure the Json is returned want to show the message to the user.</p>
  
  <pre><code>        var frm = $("#send-contact"),  // our form
              url = frm.attr("action"),  // our post action
              dta = frm.serialize();     // our data to be posted
  
          $.post(url, data, function(data) {
              // data has our returned Json from our view
  
              //$(".myModal").Show(stResult); Instead I want a place like here to just show the result
              $(".error-message").text(data.message); // just to see it, do what you want
              //$(".loading").hide(); // no more loading as we have what we need
          });
  </code></pre>
  
  <p>--
  Also I'm eager to know how to return and show the stResult when the json returned.
  Thanks for any further completion of you answer and your help.</p>