我对在 Perl 中的 js 中使用模态有一些困惑,在我的例子中,我有一个带有按钮的 View 文件
<button type="button" id="helloWorld" ></button>
当用户点击 helloWorld
时会请求一个数组即JS用于从 Controller 调用数组,
var URL = encodeURI("/helloWorld");
$('#modal').load(URL, function(result){
$('#Modal').modal({show:true});
});
以便返回的数据用于加载模式,但现在我想隐藏模式并在返回的数组为 NULL 时显示错误消息, 如何仅在数组不为 NULL 时才加载数据 谁能给我一些解决上述问题的提示
最佳答案
您可以执行以下操作来检查结果值是否为 NULL,然后显示模式,否则执行其他操作。
if (result) {
$('#myModal').modal({show:true});
}else { # do someting if required }
关于javascript - 使用perl在js中隐藏模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36986333/