Click here to Skip to main content
15,922,407 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to asp classic and trying to call asp classic function from jquery ajax but it is giving 404 error. I want to return records in json in this javascript code.

My javascript code is
JavaScript
$.ajax({
 type: "POST",
 url: "../dbFile.asp",

 data: {"Id"="10"},
 error: function(XMLHttpRequest, textStatus, errorThrown){
     alert(textStatus);
 },
 success: function(result){
    alert("success");
 }
});
 return false;
});


and my vb script function in asp classic file is

VB
Function GetAllRecords()
   dim cmd, rs

   set cmd=Server.CreateObject("ADODB.Command")

   cmd.ActiveConnection = conn

   cmd.CommandType = 4

   cmd.CommandText = "GetAllRecords"

   set rs=Server.CreateObject("ADODB.Recordset")

   set rs=cmd.Execute()

   set GetAllRecords= rs

   set rs=nothing

   set cmd=nothing

End Function

Please guide i am stuck here.
Posted
Updated 2-Sep-13 19:26pm
v4
Comments
Nelek 2-Sep-13 12:49pm    
Is it possible that you are missing one quote (") in your Javascript? In the line:
data: ("Id="10 "),
Sergey Alexandrovich Kryukov 2-Sep-13 12:50pm    
Calling or sending Ajax HTTP request? You cannot call ASP functions (server side) from client side.
—SA
touseef4pk 3-Sep-13 1:25am    
I am actualy tring ot get data from asp file in ajax success. Now with modification it is calling server but no data returns... parseerror i am receiving

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900