0

I'm trying to load a piece of code every time there is a change in a drop downs selection. I thought the best way to do this would be to .load the file but that doesn't seem to bring the asp/sql across.

How do I make the following code work:

$(document).ready(function() {
    $("#abn").change(function () {
    $("#searchUpdate").load("sql.asp");
})
.change();
});

Error:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/junk/dbinstant.htm, line 27

Page code:

<%@ LANGUAGE="VBSCRIPT" %>
<%
pagetitle="Contractor Details"
%>
<!--#INCLUDE VIRTUAL="/_lib/include/header.htm"-->
<!--#INCLUDE VIRTUAL="/_lib/include/menu.htm"-->
<script>
$(document).ready(function() {
    $("#abn").change(function () {
    $("#searchUpdate").load("sql.asp");
})
});
</script>
<div class="twoColumnRow">
<div class="twoColumnContent">
<p class="breadCrm"><a href="/index.htm">Home</a> <span>&gt;</span> <a href="/tools/index.htm">Tools of the Trade</a> <span>&gt;</span> <a href="/tools/finance/index.htm">Finance and Purchasing</a><span>&gt;</span> <a href="/tools/finance/procurement/index.htm">Procurement and Contracts information</a></p>
<div class="contentPad">
<!-- Start of main content -->

<p class="imageRight">&nbsp;</p>
<h1><%=pagetitle%></h1>


<div id="searchUpdate"></div> 
<h2>Search results</h2><hr />
<% if not con.BOF then %>
<div style="margin-top:1em">

  <form action="dbresults.htm" method="get">

      <p>Company name:<br/>
      <select id="abn" name="abn">
        <option label="All companies" value="all"></option>
        <% while (NOT scon.EOF) %>
        <option label="<%=scon("legal")%>" value="<%=scon("abn")%>"></option>
        <%scon.MoveNext()
                          Wend %>
      </select>
      </p>
     <p>Categories for Creative Design:<br/>
      <select id="cat" name="cat">
        <option class="group" label="All categories" value="all"></option>
        <option class="group" label="Strategic brand, marketing and communications advice" value="a"></option>
        <option class="group" label="Graphic design and layout" value="b"></option>
        <option class="group" label="Forms design" value="c"></option>
        <option class="group" label="Web design and development" value="d"></option>
        <option class="group" label="Authoring services" value="e"></option>
        <option class="group" label="Editorial services" value="f"></option>
        <option class="group" label="Translation services" value="g"></option>
        <option class="group" label="Photography and film services" value="h"></option>
        <option class="group" label="Scanning and digitisation services" value="i"></option>
        <option class="group" label="Multimedia editing services" value="j"></option>
      </select>
    </p>
    <input type="submit" value="Search" />
  </form>
  <br /><hr />

    <table style="font-size:.9em;" class="contentTable">
          <tr>
                <th>ABN:</th>
                <th>Company Name:</td>
          </tr>
  <% con.Movefirst() %>
  <% while (NOT con.EOF) %>
          <tr>
                <td><%=con("abn")%></th>
                <td><a href="dbcomp.htm?abn=<%=con("abn")%>&cat=all"><%=con("legal")%></a></td>
          </tr>
  <%
    con.MoveNext()
    Wend
  %>
</table>



</div>
<% else %>
    <% scon.Movefirst() %>
  <form action="dbresults.htm" method="get">

      <p>Company name:<br/>
      <select name="abn">
        <option label="All companies" value="all"></option>
        <% while (NOT scon.EOF) %>
        <option label="<%=scon("legal")%>" value="<%=scon("abn")%>"></option>
        <%scon.MoveNext()
                          Wend %>
      </select>
      </p>
     <p>Categories for Creative Design:<br/>
      <select name="cat">
        <option label="All categories" value="all"></option>
        <option label="Strategic brand, marketing and communications advice" value="a"></option>
        <option label="Graphic design and layout" value="b"></option>
        <option label="Forms design" value="c"></option>
        <option label="Web design and development" value="d"></option>
        <option label="Authoring services" value="e"></option>
        <option label="Editorial services" value="f"></option>
        <option label="Translation services" value="g"></option>
        <option label="Photography and film services" value="h"></option>
        <option label="Scanning and digitisation services" value="i"></option>
        <option label="Multimedia editing services" value="j"></option>
      </select>
    </p>
    <input type="submit" value="Search" />
  </form>
  <br /><hr />
<p>No records match your query.</p>
<p><a href="dbtest.htm">Return to search page</a></p>
<%
  end if
  con.close
%>


<!-- End of main content -->
</div> <!-- end contentPad div -->
</div> <!-- end twocolumncontent div -->
<div class="twoColumnLinks">

<!--<div class="relatedLinks">
<h3>Related Links</h3>
<ul>
<li><a href="/index.htm">Related link 1</a></li>
</ul>
</div>--> <!-- end relatedlinks div -->
<!--#INCLUDE VIRTUAL="/_lib/include/quicklinks.htm"-->
<!--#INCLUDE VIRTUAL="/_lib/include/mylinks.htm"-->
</div> <!-- end twocolumnlinks div -->
</div> <!-- end twocolumnrow div -->
<!--#INCLUDE VIRTUAL="/_lib/include/footer.htm"-->

THE ASP PAGE CODE:

<%
        Dim connectString, connect, conDB, sconDB, con, scon, src_abn, src_cat
        connectString = "Driver={Microsoft Text Driver (*.txt; *.csv)}; DBQ=" & Server.MapPath("data")
              src_abn = Request.QueryString("abn")
              src_cat = Request.QueryString("cat")
        set connect = Server.CreateObject("ADODB.connection")
        connect.open connectString

        if src_abn = "all" and src_cat = "all" then
        conDB = "SELECT * FROM cont.csv"    
        elseif src_abn = "all" then
        conDB = "SELECT * FROM cont.csv WHERE " & src_cat & " = 'Yes'"  
        elseif src_cat = "all" then
        conDB = "SELECT * FROM cont.csv WHERE ucase(abn) LIKE ucase('%"+src_abn+"%')"   
        else 
        conDB = " SELECT * FROM cont.csv WHERE " & src_cat & " = 'Yes' AND ucase(abn) LIKE ucase('%"+src_abn+"%')"
        end if

        sconDB = "SELECT * FROM cont.csv"   

        set con = connect.execute(conDB)
        set scon = connect.execute(sconDB)
%>
5
  • what do you mean by doesn't seem to bring? Is it not loading sql.html? And what is purpose of .change() call after handler? Commented Jan 10, 2013 at 0:42
  • .load() will load the generated html contents of sql.htm fully into the div #searchUpdate. Why do you have .change() on $(document).ready? Commented Jan 10, 2013 at 0:45
  • My bad, left that in there. It won't load the asp code in. It brings up an error: Microsoft VBScript runtime error '800a01a8' Object required: '' /junk/dbinstant.htm, line 26 (I'll add the code to the post) Commented Jan 10, 2013 at 0:49
  • 1
    Your asp code will not be loaded by jQuery (I repeat, only the generated html). Since you get an asp error, you have an error in sql.asp that is asp related. The problem is not with jQuery. Commented Jan 10, 2013 at 0:55
  • Please confirm. The server will execute the ASP/SQL in sql.asp and then return it as html? If that is the case, when I replace the div with the asp in the one page it works. So what could cause that? (I'm including the asp file in the post) Commented Jan 10, 2013 at 1:00

1 Answer 1

2

Hopefully I'm pointing out the obvious here. jQuery works client side and can makes calls to the server via ajax to retrieve more HTML. You will not be able to "load" ASP and SQL into your page this way. What you can do is call a serverside asp page that will execute the ASP and SQL which then returns some HTML to your page. The clue here is you are calling "sql.htm" which will be default not execute any thing serverside. I would have expected the call to be to something like "sql.asp" which would execute serverside then return something useful to you.

Sign up to request clarification or add additional context in comments.

2 Comments

It all helps. I have completed those changes but now I get the following error: Microsoft VBScript runtime error '800a01a8' Object required: '' /junk/dbinstant.htm, line 26 Please note that when I put the code from the sql.asp in the actual file in place on the div, it works.
Maybe you'd better give your ASP files the .asp extension?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.