小编Fra*_*int的帖子

未使用(承诺)取消使用SweetAlert2

如何在使用promises时正确转义取消按钮而不会抛出错误?我的代码会抛出一个带有必填复选框的警报确认.代码应该对用户执行,但它会在控制台窗口中引发错误:

未被捕(承诺)取消

//validation logic all passes...Now proceed to...

 else
    {

//determine and parse Discounts

 var myLookup = document.getElementsByName("myLookup")[0].value;
$.post( "findthem.php", {myLookup: myLookup })
  .done(function(json_data){
     var theResponse1 = $.parseJSON(json_data);
     myDiscountRate = theResponse1['ourDiscountFound'];

    }).then( function(callback){

    priceRate = priceRate * (1 - (.01 * myDiscountRate));
    newRate = priceRate.toFixed(2);
}

swal({
  title: "Confirm",
  input: 'checkbox',
  inputValue: 0,
  type: "warning",
  inputPlaceholder: 'I agree to <a href="#blahblahMore"></a> Your new Rate is :'+newRate,
  showCancelButton: true,
  confirmButtonText: 'Confirm',
  showLoaderOnConfirm: true,
  preConfirm: function(result) {
    return new Promise(function(resolve, reject) { …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery sweetalert sweetalert2

16
推荐指数
3
解决办法
2万
查看次数

SMTP TLS不适用于Gmail

我想编写一个使用SMTP TLS连接gmail服务器的程序.我使用的是本页提到的代码:

http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/

我正在连接超时异常.如果我使用SMTP SSL,我可以成功发送电子邮件.

public void sendUsingSMTP_TLS() {
    final String username = "username@gmail.com";
    final String password = "password";

    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", "smtp.gmail.com");
    props.put("mail.smtp.port", "587");

    Session session = Session.getInstance(props,
      new javax.mail.Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(username, password);
        }
      });

    try {

        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress("from-email@gmail.com"));
        message.setRecipients(Message.RecipientType.TO,
            InternetAddress.parse("to-email@gmail.com"));
        message.setSubject("Testing Subject");
        message.setText("Dear Mail Crawler,"
            + "\n\n No spam to my email, please!");

        Transport.send(message);

        System.out.println("Done");

    } catch (MessagingException e) { …
Run Code Online (Sandbox Code Playgroud)

java email gmail smtp

1
推荐指数
1
解决办法
6857
查看次数

标签 统计

ajax ×1

email ×1

gmail ×1

java ×1

javascript ×1

jquery ×1

smtp ×1

sweetalert ×1

sweetalert2 ×1