1

I'm coding in Classic ASP.

I have a form which searches through a database, and I wish to load the results with AJAX in jQuery. I would like the search to be activated every time there is a change in the form fields, so the following is my jQuery script

$(document).on('change', '.ops', function() {
    //Count number of rows in field
    var noofrows = $('.criteriallist').children().length;

$.ajax({url:"searchresults.asp?criteria=" + noofrows, success:function(result) { 
    $("#resultstable").html(result); 
   }
});
}); 

What I would like to ask is: am I able to use "Request.Form("fieldname") to get the fieldnames, or should I input the form data through the QueryStrings? I have tried using the Request.Form method and it does not work, but it detects my QueryStrings.

kosherjellyfish
  • 353
  • 4
  • 15

1 Answers1

1

yes that is possible you have to set a Parameter in the Ajax call of jquery as the Standard way is "get" and so the Parameters are only availbe through Request.QueryString.

So just add

$.ajax({
    type: "post",
    url:"searchresults.asp?criteria=" + noofrows, 
    success:function(result) { 
        $("#resultstable").html(result); 
    }
});

then the request is send by a http post and you can Access the Parameters on the serverside by Request.Form

ulluoink
  • 2,727
  • 2
  • 14
  • 22