我想从JS的Java小程序中调用方法。我对如何安排我的工作流程有点困惑。我有一个包含javascript(pending.js)的jsp(pending.jsp)类。 pending.jsp只是一个容纳pending.js的容器。 pending.js的目的是让用户取消创建报告。JSP - JS - Java交互
pending.jsp:
<div id="pending-reports-container" class="pending-reports-container">
<div id="pending-reports">
</div>
</div>
pending.js:
function update_pending_reports(response_data)
{ bla }
function delete_report(report_id)
{ bla }
function request_pending_reports()
{ bla }
function start_pending_reports() {
request_pending_reports();
setInterval("request_pending_reports()", 5000);
}
由于取消报告有时是不是有效我想用Java来请求取消行进至Postgres的(待定。 js不会杀死在postgres中工作的进程)。我创建了我的Java类,但我不知道在哪里添加它。我知道我可以使用标签的,但是当我试图给这个标签添加到我的JSP文件是这样的:
<div id="pending-reports-container" class="pending-reports-container">
<div id="pending-reports">
<applet id="LS" width=1 height=1 code ="module/LicenseCheckService.class" codebase="."/>
</div>
</div>
我不能使用此代码从我pending.js实现它:
getJS = document.getElementById("LS");
我的代码有什么问题,或者我在这个结构中错了吗?
不要将字符串传递给'setInterval'。传递函数:'setInterval(request_pending_reports,5000);'或者如果你需要参数:'setInterval(function(){request_pending_reports(something);},5000);' – ThiefMaster