title: Success callback not working in $.getJSON
body: <p>
  I have a cross domain webservice which i want to call, however when i try to call it, i get a proper response in json (checked in firebug) but success callback never fires, instead it executes the error callback.
  </p>
  
  <p>Here is my javascript code.</p>
  
  <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
      $(document).ready(function () {
              $.getJSON("http://[external domain]/Service.asmx/SendMail?callback=?", { 'body': txtEmail.value }, function (data) {
                  alert("SUCCESS");
              })
              .error(function (data) { alert("ERROR: " + data.responseText); })
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is my webservice code.</p>
  
  <pre><code>&lt;%@ WebService Language="C#" Class="Service" %&gt;
  using System;
  using System.Web;
  using System.Web.Services;
  using System.Web.Script.Services;
  using System.Net.Mail;
  using System.Web.Script.Serialization;
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
  [ScriptService]
  
  public class Service : System.Web.Services.WebService
  {
      [WebMethod]
      [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
      public void SendMail(string body)
      {
          Context.Response.Clear();
          Context.Response.AddHeader("Access-Control-Allow-Origin", "*");
          Context.Response.ContentType = "application/json";
          JavaScriptSerializer js = new JavaScriptSerializer();
          try
          {
              MailMessage message = new MailMessage();
              message.From = new MailAddress("[senders mail]");
              message.To.Add("[recepient mail]");
              message.IsBodyHtml = true;
              message.Priority = MailPriority.High;
              message.Subject = "[subject]";
              message.Body = body;
  
              SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
              client.EnableSsl = true;
              client.Credentials = new System.Net.NetworkCredential("[username]", "[password]");
              client.Send(message);
  
  
  
              string str = "{\"value\" : \"sent\"}";
              // also tried with JavascriptSerializer like in catch block, that too not working.
              Context.Response.Flush(); 
              Context.Response.Write(str);
  
  
          }
          catch(Exception ex) 
          {
              string str = js.Serialize(ex.Message);
              Context.Response.Flush();
              Context.Response.Write(str);
          }
  
      }    
  }
  </code></pre>
  
  <p>Below is the response traced in firebug.
  <img src="https://i.stack.imgur.com/bzUC1.jpg" alt="enter image description here"></p>
  
  <p>can anyone tell me what could be the issue.</p>