在 jcertify.html 中有:
<!-- Bootbox utilities
================================================== -->
<script src"../static/assets/js/email_sign_up.js"></script>
</body>
email_sign_up.js 中的有:
function emailSignUp( )
{
bootbox.prompt("<strong>Email address</strong>Enter email address where the report should be send to : ", function(result) {
if (result) {
// Example.show("email: <b>"+result+"</b>");
console.log("NikoS");
}
});
}
jcertify.html 中的就像:
<p><a href="javascript:console.log('hi there');emailSignUp();" class="bb-trigger btn btn-primary btn-lg btn-block">Sign up</a></p>
在浏览器的调试器中,当我点击“注册”按钮时,我看到的是:
[日志]你好(jcertify,第1行) [错误] ReferenceError:找不到变量:emailSignUp 全局代码(jcertify,第1行)
你知道我做错了吗?答案 0 :(得分:0)
检查这个jsfiddle:
http://jsfiddle.net/f75nfL26/1/
HTML:
<a class="bb-trigger btn btn-primary btn-lg btn-block">Sign up</a>
JS:
$('.bb-trigger').on("click", function(e) {
bootbox.prompt("<strong>Email address</strong>Enter email address where the report should be send to : ", function(result) {
if (result) {
// Example.show("email: <b>"+result+"</b>");
console.log("NikoS");
}
});
});
在那里工作正常
答案 1 :(得分:0)
$(document).ready(function() {
$(document).on("click", "#signin_session", function(event) {
event.preventDefault() ;
bootbox.prompt("<strong>Email address</strong><br>Please enter the email address where the report should be send to : ", function(email_address) {
if (email_address) {
formulate = {'email_address': email_address} ;
$.ajax({
url: "/jcertify/session-report/",
data: JSON.stringify(formulate,null), // {'email_address': email_address},
type: "POST",
contentType: "application/json;charset=UTF-8",
success: function(response) { document.write(response) ; },
error: function(error) { console.log(error) ; }
});
}
});
});
});