title: Formatting JSONP for cross domain webservice in Jquery
body: <p>i have webservice on external domain, which contain a web-service for sending mails</p>
  
  <p><p>I want to call cross-domain web-service using jquery ajax, the problem is i could not get the success value, it goes to error even if webservice has successfully executed and mail has been sent</p><p> i checked in the firebug (Net Tab), while executing it appends ?callback=[some junk function], and because it does not finds that function, it does not displays proper message.</p>
  below is my webmethod</p>
  
  <pre><code>[WebMethod]
  [ScriptMethod(ResponseFormat=ResponseFormat.Json)]
  public string SendMail()
  {
      string returnVal = string.Empty;
      try
      {
          MailMessage message = new MailMessage();
          message.From = new MailAddress("[from]");
          message.To.Add("[to]");
          message.Subject = "TEST";
          message.Body = "TEST MAIL";
          message.Priority = MailPriority.High;
          SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
          client.EnableSsl = true;
          client.Credentials = new NetworkCredential("[username]", "[password]");
          client.Send(message);
          returnVal = "[mycallback]({'status':'Success'})";
      }
      catch (System.Exception ex) { returnVal = "[mycallback]({'status':'Fail Reason: " + ex.Message + "'})"; }
      return returnVal;
  }
  </code></pre>
  
  <p>and below is my ajax jquery call</p>
  
  <pre><code>    $(document).ready(function(){
              $.ajax({
                  type:"GET",
                  url:"http://audiomedia.dev.asentechdev1.com/MailSender.asmx/SendMail",
                  dataType:"jsonp",
                  jsonpCallback: 'mycallback',
                  success: function(data){
                      alert(json.Parse(data));
                  },
                  error: function (data) {
                      alert("Error: " + data.responseText);
                  }   
              });
              function mycallback(data){
                  alert("CallBack: " + JSON.stringify(data));
              }
          });
  </code></pre>
  
  <p>with changing the return value and adding callback i get below reply from server
  <img src="https://i.stack.imgur.com/iO1ol.jpg" alt="enter image description here">
  but still its going into the error callback, even after successfully sending mail.
  can anyone tell me how can format the success message.</p>