Passing Classic ASP values in AJAX

Bob Schneider
Bob Schneider used Ask the Experts™
on
I would like to tie this one off soon if we could.  On this page I am using an array to populate a datatable and I want to pass three values:
1) series id
2) age category
3) gender

The dropdowns are there.  I understand that this is not done via forms.  My dropdowns are:
1) series
2) categories
3) gender

I have learned a ton from this site on this but still having difficulty connecting these dots.

Thanks so much in advance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
Your jquery would change to
$(document).ready(function() {
var series = 0;
var categories = 0;
var gender = 0;
$('#series').on('change',function(){
  series = $(this).val();
 });
$('#categories').on('change',function(){
  categories = $(this).val();
 });
$('#gender').on('change',function(){
  gender = $(this).val();
 });


    $('#standings').dataTable( {
        'ajax': '/series/results_array-new.asp?series_id='+series+'&gender='+gender+'&year=2014&age_to='+categories;
    } );
  
  
} );

Open in new window

Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
Correction

$(document).ready(function() {
var series = 0;
var categories = 0;
var gender = 0;
$('#series').on('change',function(){
  series = $(this).val();
  categories = $('#categories').val();
  gender = $('#gender').val();
   getData(series,categories,gender);
 
 });
$('#categories').on('change',function(){
  series = $('#series').val();
  categories = $(this).val();
 gender = $('#gender').val();
 });
$('#gender').on('change',function(){
   series = $('#series').val();
   categories = $('#categories').val();
  gender = $(this).val();

 });

  function getData(series,categories,gender){
      // for testing
  alert (series+ ' '+gender + ' '+ categories);
   
      $('#standings').dataTable( {
        'ajax': '/series/results_array-new.asp?series_id='+series+'&gender='+gender+'&year=2014&age_to='+categories;
    } );
  

  
  }
  
  
} );

Open in new window

You can see the pop up sending values here http://jsbin.com/yaboro/2/edit
Bob SchneiderCo-Owner

Author

Commented:
Thanks, but now how do I convert those in to asp variables on the "receiving" page?
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
You already have the reviving page working.  On this page, you are simply sending data.   You had hard coded data and I converted it to use javascript variables.  Those variables are taken from the drop downs.
Bob SchneiderCo-Owner

Author

Commented:
Sure, and this may be my ignorance, but the receiving page is drawing it's data from Request.Querystring.  Is that how this is being received?  I assume so but the page is now not rendering.
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
Looks like you are missing the function.  Note the code here http:Q_28509347.html#a40297150 and sample html http://jsbin.com/yaboro/2/edit that does not contain any javascript on the drop downs.
Bob SchneiderCo-Owner

Author

Commented:
HI.  So I copied your code exactly as is and it appears to not be working.  Any ideas?
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
Make sure you update the other html code.   Remember you have to take out the js in each of  your selects.  


 <select name="series" id="series" onchange="this.form.submit1.click();">
Developer & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
Start validating your code   http://validator.w3.org/
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
I hope that worked for you.  When you start using more javascript, it is important to make sure your code is good as it can be the culprit for what could seem like unrelated js errors.
Bob SchneiderCo-Owner

Author

Commented:
Yeah I see a lot of issues with the stuff I pulled down from some third parties as well so I will have to go through that more carefully.  But yes, your assistance helped a lot.  Once I get it "cleaned up" it will be a big help to this utility and to my learning curve with javascript, json, jquery, and ajax.

Thanks so much...
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
What you might want to do is recreate the table on a blank page and only deal with the 3 drop downs and table.  That takes all the other stuff out of it.  Once you get the test page to work, if it does not work on the live  page, you know it is the other stuff interfering.  That is how I would attack this.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial