I've working on a large asp classic site and trying to introduce couple of new vbscript function that will be triggered from jQuery based on some event, after which jQuery will do a partial update of the page.
My question is: If all the code (ASP classic vbscript function + html and jquery) are all in the same file (there are many vbscript functions in this page), how can i make a ajax call to a function in this page, get it to be processed on server and respond back.
So for example:
<html>
<head>
.....
<%
Function checkUsername( ....)
....
end function
Function checkCredentials( .... )
.....
end function
%>
<script>
$(document).ready(function(){
$( "#username" ).blur(function() {
var username = $('#username_field").val();
checkUsername(username);
});
function checkUsername(usr) //the function that loads pages via AJAX
{
$.ajax({
type: "GET",
url: "WHAT TO PUT HERE?????",
data: usr,
cache: false,
success: function(msg){
....
}
});
}
});
</script>
</head>
<body>
....
Username: <input type="text" name="username" id="username">
.....
</body>
</html>
Best Answer
You can't directly call a VBScript function from jQuery/JavaScript/AJAX per se, but you could just pass a URL variable that triggers your ASP code to run a specific VBScript function and then stop.
I'm not too familiar with the jQuery ajax function, but if you specified something like the following:
It should call your page again with the username passed as the
u
query string variable. Then, somewhere near the start of your ASP code, you'd want to do something like this: