使用甜蜜警报时的JS重定向

时间:2017-09-04 11:51:08

标签: javascript

我正在为我的网站使用甜蜜警报,但想知道一旦用户确认了他的行动,我如何执行另一个页面中的php脚本。

以下是代码示例:

HTML

<a href="#"><p onclick="go()">Approve/Refuse</p></a>

JS

function go() {
  swal({
    title: 'Are you sure?',
    text: "You won't be able to revert this!",
    type: 'warning',
    showCancelButton: true,
    confirmButtonText: 'Validate user',
    cancelButtonText: 'Refuse request',
    confirmButtonClass: 'btn btn-success',
    cancelButtonClass: 'btn btn-danger m-l-10',
    buttonsStyling: false
  }).then(function() {
    swal(
      'User validated!',
      'The user has been notified.',
      'success',
    )
  }, function(dismiss) {
    // dismiss can be 'cancel', 'overlay',
    // 'close', and 'timer'
    if (dismiss === 'cancel') {
      swal(
        'User refused',
        'The user has been notified.',
        'error'
      )
    }
  })
};

0 个答案:

没有答案