gpt4 book ai didi

javascript - 从 div 和 javascript/jquery 调用 cgi 脚本

转载 作者:行者123 更新时间:2023-11-29 21:14:18 25 4
gpt4 key购买 nike

我有一个 index.cgi,它有一个像这样的 div

<div id="AddCodeTab">
<div id="CodeContainer" style="width: 100%;"></div>
</div>

所以这个 div 从 addcode.js 获取它的内容

我有另一个cgi页面databasecall.cgi

那么我该如何定义 addcode.js 以便 div 中的下拉框将从另一个 cgi 页面 databasecall.cgi

获取它的值

最佳答案

在您的 addcode.js 中包含以下代码。

$(document).ready(function(){

$.ajax({url: "databasecall.cgi", success: function(result){
$("#ajaxElement").html(result);
}});

});

并且您的 index.cgi 应该已加载 jQuery 库。它应该看起来像这样......

<!doctype html>
<html>
<head>
</head>
<body>
<h1>Loading a CGI file via jQuery/AJAX</h1>
<!-- more content -->
<header id="pageHeader"><h2>This section is populated using jQuery/AJAX</h2>
<div id="ajaxElement"></div>
</header>
<!--more content -->
<!-- absolute or relative path to your jQuery Library. You can also use CDN from jQuery.org. I use npm to install mine. -->
<script src="/node_modules/jquery/dist/jquery.min.js"></script>
<!-- make sure your path to jQuery libray is correct -->
<script src="addcode.js"></script>
</body>
</html>

关于javascript - 从 div 和 javascript/jquery 调用 cgi 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40132443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com