Using Ajax with Classic ASP [Answered]RSS

6 replies

Last post May 12, 2008 10:16 PM by MyronCope

  • Using Ajax with Classic ASP

    May 11, 2008 11:43 AM|MyronCope|LINK

    I have 2 comboboxes on an ASP page and I need the following behavior:

    1. user selects a value on combobox1

    2.  this fires a javascript that uses Ajax to call some VBscript, I will call it queryDB()

    3.  the VBScript function queryDB() returns a recordset of records from the database

    4. bind the recordset to ComboBox2

    The main thing that I'm stuck on is part 2, using Ajax to call a VBScript function.  I now know I have to use some kind of Ajax because the page cannot postback.  Does anyone know how to do this?  any code samples would be great.

    also is it possible to use a recordset or do i have to return the data in xml form?  I posted a similar question already but I am posting this because I realize that I did not mention Ajax in my other initial post and this is the key point that I need to figure out, how to use Ajax with Classic ASP.


  • Re: Using Ajax with Classic ASP

    May 11, 2008 02:12 PM||LINK

    ASP doesn't work like ASP.NET.  Write the entire thing as ASP or move to ASP.NET.  Frankly, it doesn't sound like you should need to shell to an external VBScript just to query a database anyway.


    Have you Binged a solution before posting?
  • Re: Using Ajax with Classic ASP

    May 12, 2008 08:48 AM|MyronCope|LINK

    The page is in classic ASP, I cannot change this. 

    Also, the requirement states that the page cannot refresh so I assume that I will have to implement some Ajax like coding there.

    If you know of another way that I can accomplish this I would be thrilled to hear about it.

  • Re: Using Ajax with Classic ASP

    May 12, 2008 09:03 AM|tomkmvp|LINK

    How much data are we talking about?  One technique is to load all of the data at once into the client-side code of the page. Take a look at some of the examples here:

  • Re: Using Ajax with Classic ASP

    May 12, 2008 09:10 AM|MyronCope|LINK

    not too much data but here is the situation:

    ComboBox1 can be loaded during pageload.

    but ComboBox2 values must be loaded when you change ComboBox2 because the values in ComboBox2 are dependent on what you choose in ComboBox1.

    I guess you can think of it like this:

    ComboBox1 could be states in the US.  When you select a state it will show corresponding cities that are in that selected state in ComboBox2.

  • Re: Using Ajax with Classic ASP

    May 12, 2008 09:17 AM|tomkmvp|LINK


    If you can't refresh then you have two options:

    1)  my link above on DHTML and data binding

    2)  AJAX.  Have you seen this?,GGLG:2006-01,GGLG:en&q=ajax+with+classic+asp

  • Re: Using Ajax with Classic ASP

    May 12, 2008 10:16 PM|MyronCope|LINK


    thanks for your feedback.  I got it working! I pretty much followed this page, their ajax tutorial is great, highly recommended:

     I followed this exactly except for the asp page (think the example is called getcustomer.asp), instead of writing out the values I loop through each record and create a combobox option for each record returned:


    do until rs.EOF      response.Write("<option value=" & rs("ID") & ">")







    Otherwise my code is the same (except of course changing page names and similar things).

    If anyone wants to do this the link above should help you but let me know by posting here if you have any questions.