javascript - 使用 JQuery 在 HTML 按钮中运行 python 脚本
问题描述
我有一个 python 脚本,当我单击 html 页面上的按钮时,我想执行它。我正在使用 JQuery 来做到这一点。出于某种原因,它什么也没做。我是否缺少任何权限或某些语法?没有把握。
我正在为我的应用程序使用 WebApp2 框架。
这是代码。
<input type="button" name="" value="run" onclick="goscript()">
<script
src="http://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous"></script>
<script>
function goscript(){
$.ajax({
url:"fb.py",
context: document.body
}).done(function(){
alert('finished python script');;
});
}
</script>
我的 python 文件位于模板所在的同一 html 目录中。
我对编码很陌生,请提供任何建议或帮助。
解决方案
推荐阅读
- android - 使用透明背景颜色自定义 Spinner 对话框,并在其项目之间设置分隔符
- reactjs - 如何在多个渲染输入中使用钩子?
- laravel - 在本地主机上运行 php artisan serve 命令时出错
- timer - 如何在猫鼬操作系统的任何循环中实现定时器和延迟?
- sql - 子查询返回多个值
- html - 如何将组件对齐在整个页面的中心?
- hardware - 如果我们无法区分它们,为什么 Vulkan 中队列族中的队列需要优先级?
- python - 在我的 django 应用程序中,我在哪里实现这个 get_client_ip() 函数?
- python - 如何在keras的LSTM中输入排名
- angular - DocuSign:对于 Angular 应用程序 - 为什么 OAuth 重定向 URL 不能包含片段指示符 (#)?