SweetAlert 2 通过 Ajax 请求传递值不起作用

SweetAlert 2 pass values over Ajax Request doesn't work

我是 js 编程新手。

目前,我正在尝试将甜味剂弹出窗口的值传递给我的 php 查询。但它不起作用。(如果我按下确认按钮,表格将被关闭并且没有任何反应)。 这是我的js代码。

function ChangePassword(){
   swal({
    title: 'Kennwort ändern',
    html:
      '<input id="swal-input1" placeholder ="altes Kennwort" class="swal2-input">' +
      '<input id="swal-input2" placeholder ="neues Kennwort" class="swal2-input">' +
      '<input id="swal-input3" placeholder ="Kennwort wiederholen" class="swal2-input">',
    focusConfirm: false
    }) .then(function(isConfirm) {
        $.ajax({
            type: 'POST',
            url: 'ChangePassword.php',
            data:  {
                'pw_old': document.getElementById('swal-input1').value,
                'pw_new': document.getElementById('swal-input1').value,
                'pw_newconf': document.getElementById('swal-input1').value
            },
            success: function(result) {
                swal({
                    title: result,  
                    type: "success"}

                );
            },
        })

    })

}

谁能告诉我我的错误在哪里?

您输入的id有误。

正确代码如下:

函数更改密码(){

  swal({
   title: 'Kennwort ändern',
   html:
     '<input id="swal-input1" placeholder ="altes Kennwort" class="swal2-input">' +
     '<input id="swal-input2" placeholder ="neues Kennwort" class="swal2-input">' +
     '<input id="swal-input3" placeholder ="Kennwort wiederholen" class="swal2-input">',
   focusConfirm: false
   }) .then(function(isConfirm) {
       $.ajax({
           type: 'POST',
           url: 'ChangePassword.php',
           data:  {
               pw_old: document.getElementById('swal-input1').value,
               pw_new: document.getElementById('swal-input2').value,
               pw_newconf: document.getElementById('swal-input3').value
           },
           success: function(result) {
               swal({
                   title: result,  
                   type: "success"}             
               );
           },
       })

   })
}

希望能解决你的问题