javascript - 无需单击任何确定或取消图标即可打开 swal
问题描述
我正在使用 sweetalert 2,我只需要打开 swal 直接调用 ajax 而不是进行确认或其他操作,我需要做什么更改,遵循此代码
https://sweetalert2.github.io/recipe-gallery/bootstrap.html
像这样尝试过
$(document).on('click','.readmore',function() {
swal({
title: 'ajax request pending',
text: 'processing request',
showConfirmButton: false,
closeOnConfirm: false,
preConfirm => function(){
url: 'https://example.com/controller/method/action',
type: post,
dataType: json,
data: { key: value },
success: swal.confirm( response.message ),
error: swal.confirm( response.message )
}
},
function(){
swal({
title: 'ajax request finished',
text: response.message,
showSpinner: false,
showConfirmButton: true,
closeOnConfirm: true
});
}
});
但它最终出现了错误:d
Uncaught SyntaxError: missing : after property id
解决方案
推荐阅读
- node.js - Nodejs Cognito cognitoUser.authenticateUser() 在 lambda 上获得 502 bad gateway
- autodesk-forge - 是否可以通过 Revit API 或 FORGE API 在 Revit 模型中加载新的 Cloud (BIM 360) 链接?
- python - Dango 2.2 使用关键字参数反转“激活”
- phpstorm - WebStorm 和 PhpStorm 中所有项目的相同 SFTP 远程主机
- python - 在 Python 中导入 Dialogflow 时出错
- assembly - x86 程序集:尝试反转打印数组时出现分段错误(核心转储)
- php - 如何获取完整的 URL 以在 laravel 中显示
- sas - 合并两个数据集
- c - memcpy 导致分段错误
- excel - 在值列表中搜索所有值并将所有找到的值返回到相邻单元格中