I'm new to asp. I have a submit button called "search" in a file called results.asp. I just need to run an asp function called "searchRecords" in the same file as the search button when the button gets clicked. Without redirecting to another page. I tried doing everything, using js, vb script... nothing works the way I want.
我是asp的新手。我在名为results.asp的文件中有一个名为“search”的提交按钮。我只需要在单击按钮时在与搜索按钮相同的文件中运行名为“searchRecords”的asp函数。无需重定向到另一个页面。我尝试做所有事情,使用js,vb脚本...没有按照我想要的方式工作。
the submit button:
提交按钮:
<form action="what goes here?">
<input type="submit" value="Search Records" name="search">
</from>
the function:
功能:
<% function show()
...stuff here....
%>
Also I found this asp code from another file that works in same kind of situation, but it does not work in my file.
此外,我发现这个asp代码来自另一个在相同情况下工作的文件,但它在我的文件中不起作用。
<% if (request("button name")= "button value") then
function to call
end if
%>
Please help me to figure this out... thanks in advance...
请帮我弄明白......提前谢谢......
2 个解决方案
#1
1
With your case, I think you need to use Jquery ajax:
在你的情况下,我认为你需要使用Jquery ajax:
jQuery.ajax({
type:"POST" // Or GET
data:"id=12&name=abc",
dataType:"xml", // Default type - text
url:"/search/searchRecords", // URL of service
success: function (data){
}
});
If you use ASP.NET MVC, you can call a asp function direct. But with asp-classic, you only call a asp function through a service.
如果使用ASP.NET MVC,则可以直接调用asp函数。但是使用asp-classic,你只能通过服务调用asp函数。
#2
1
$.ajax({
type: "POST",
url: URL + "index.php/phpService/SaveClient/" + controllerVM_.TokenKey(),
data: JSON.stringify(ko.toJS(params)),
contentType: "application/json",
async: true,
dataType: 'json',
cache: false,
success: function (response) {
if (response.GetClientsResponse.Result != "Invelid Tokenkey !!!") {
}
else {
window.location.assign("Login.html");
}
},
error: function (ErrorResponse) {
if (ErrorResponse.statusText == "OK") {
}
else {
alert("ErrorMsg:" + ErrorResponse.statusText);
}
}
});
#1
1
With your case, I think you need to use Jquery ajax:
在你的情况下,我认为你需要使用Jquery ajax:
jQuery.ajax({
type:"POST" // Or GET
data:"id=12&name=abc",
dataType:"xml", // Default type - text
url:"/search/searchRecords", // URL of service
success: function (data){
}
});
If you use ASP.NET MVC, you can call a asp function direct. But with asp-classic, you only call a asp function through a service.
如果使用ASP.NET MVC,则可以直接调用asp函数。但是使用asp-classic,你只能通过服务调用asp函数。
#2
1
$.ajax({
type: "POST",
url: URL + "index.php/phpService/SaveClient/" + controllerVM_.TokenKey(),
data: JSON.stringify(ko.toJS(params)),
contentType: "application/json",
async: true,
dataType: 'json',
cache: false,
success: function (response) {
if (response.GetClientsResponse.Result != "Invelid Tokenkey !!!") {
}
else {
window.location.assign("Login.html");
}
},
error: function (ErrorResponse) {
if (ErrorResponse.statusText == "OK") {
}
else {
alert("ErrorMsg:" + ErrorResponse.statusText);
}
}
});