2

I have a index.cgi which has a div like

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

So this div gets its content from addcode.js

I have another cgi page databasecall.cgi

So how do I define the addcode.js so that dropdown box in the div will get its value from another cgi page databasecall.cgi

1 Answer 1

2

In your addcode.js include the following code.

$(document).ready(function(){

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

});

And your index.cgi should have jQuery Library loaded. It should look something similar to this...

<!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>
Sign up to request clarification or add additional context in comments.

1 Comment

I have tis error: cam.html:1 Failed to load xxxxxxxx/anony/mjpg.cgi: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.