views:

83

answers:

2

Hi, I am new to jquery ! I am using the code below to insert record, the data posted to targeted asp page, but nothing happen, but when I try using simple form and post with same coding , the data inserted !

Jquery Code

<script>

    $(document).ready(function(){
// code here             
   $("a").click(function(event){
 //    alert("Thanks for visiting!");
      $(this).addClass("test");
     event.preventDefault();
    $(this).hide("slow");

    $.post("suggested.asp", { profileid: "<%=(Recordset1.Fields.Item("MatchProfileID").Value)%>", seenby: "<%=(Recordset1.Fields.Item("Foruser").Value)%>" },


  function(data){
    alert("Data Loaded: " + data);
  });



   });

   //
 });


</script>

ASP CODE

<%
    ' Setting variables
    Dim rs, data_source

    data_source = "dsn=mydsn;"

    ' Creating Recordset Object and opening the database
    Set rs = Server.CreateObject("ADODB.Recordset")

    ' Lets open books table
    rs.Open "sugg", data_source

    rs.AddNew
    ' Now adding records
    rs("byid") = Request.Form("seenby")
    rs("vid") = Request.Form("profileid")
    rs.Update
Response.Write("Done")
    ' Done. Now Close the Connection
    rs.Close
    Set rs = Nothing
%>
A: 

Ok your server side code works properly. Maybe an error occurred before $.post call?

Add one more parameter to post call - 'text'. May be it was data format error

see here for details: http://docs.jquery.com/Ajax/jQuery.post#urldatacallbacktype

Trickster
Sorry, I don't know about c# ... exactly I need to pass value of current record id eg.profile id 1profile id 2profile id 3On which ever user click , i need to pass that's links value to server
Dev
Yes, now i see that it is ASP not ASP.NET
Trickster
A: 

All the code seams to be ok.

Things to check:

  1. Are you accessing the client code in the same domain (ie. //localhost) than the server code?
  2. Is the suggested.asp file in the same folder than the client code?

Things to troubleshot

*Use this simple code just to be sure there is not problem in the server side:

<html>
<head>
</head>
<body>
   <%
   dim retval, x
   retval = ""
   For x = 1 To Request.Form.count()
      retval = retval + "p:" + Request.Form.key(x) + "=" + Request.Form.item(x) + ";"
   Next

   response.clear
   response.write "params: " + retval
   response.end
   %>
</body>
</html>

*Use Firebug to check if the request is being sent and what is the response.

Eduardo Molteni