I have a html page with a form like:
<form id="goodsearch" action="test.asp" method="post">
<input type="text" id="goods" name="name"></input>
<input type="submit" id="search" value="Search"></input>
</form>
I wrote a separate script file by jQuery. When user input one a name of goods into form and click submit button, goods name is searched in DB
$("#goodsearch").submit(function() {
$.ajax({
url: "test.asp",
type: "post",
data: { "name": '"' + $("#goods").val() + '"' },
success: function(data) {
alert(Response);
}
});
return false;
});
On Server side classic ASP, I wrote some code for testing:
<%@ Language = VBScript %>
<%
dim x
x = Request.Form("name")
Response.Write(x)
%>
But nothing happen. This is my first time write code using ajax. So I don't know where is wrong.
Another a question: If I want mix server-side class asp with many functions on a html page and use jQuery with ajax to call function in asp, how do I can call a sepecific function?
Your code is right. Just change ajax success function to:
success: function(data) {
alert(data);
}