Reputation: 127
I have a Bootstrap nav and I would like to change de content of the #result div using the Include.File from ASP Classic on click. Is there a way to do this?
HTML
<body onload="">
<nav class="navbar navbar-light bg-light sticky-top shadow">
span><%=rs(2)%></span>
<ul class="nav nav-pills ml-4">
<li class="nav-item">
<a class="nav-link" style="cursor: pointer;" id="solicitar" onclick="test('solicitar.asp')">Solicitar</a>
</li>
<li class="nav-item">
<a class="nav-link" style="cursor: pointer;" id="consultar" onclick="test('consultar.asp')">Consultar</a>
</li>
</ul>
<a class="navbar-brand mx-auto" href="">
<img src="../imgs/logos/4_COL-1.jpg" width="200" height="50" class="d-inline-block align-top" alt="">
</a>
<span><%=date%></span>
</nav>
<div class="container-fluid" id="result">
</div>
</body>
JavaScript
function test(fileName) {
$.ajax({
method: "POST",
data: {},
success: function () {
$("#result").html('<!--#Include File="' + fileName + '"-->');
},
error: function (x) {
console.log(x);
},
});
}
Upvotes: 0
Views: 169
Reputation: 97707
To request a page via ajax you set the url parameter to the address of the page.
If successful you will get the page contents in the success function.
Used GET instead of POST since it was just a page request.
function test(fileName) {
$.ajax({
url: fileName,
method: "GET",
success: function (html) {
$("#result").html(html);
},
error: function (x) {
console.log(x);
},
});
}
Upvotes: 1