Solved

jquery / classic asp

Posted on 2011-09-09
2
1,636 Views
Last Modified: 2012-05-12
jquery.autocomplete.css jquery.autocomplete.js query.js
I am using Jquery with classic asp. it is simple like having classic asp to run db in a recordset
and have Jquery to pick up the data.

Everything is working fine, except in the very top that have 4 lines are empty, and I would like
to remove them but don't know how to do  that. See pdf for screen shot.

I would like jquery experts  to tell me how to erase them out...Thanks
<%
Function AjaxSearchCity(CityKeywords,DbConnection)
    'SQL = "select distinct city from address where city like '%" & CityKeywords & "%' order by city asc"
     SQL = " SELECT DISTINCT Address.City, Vanpool.Active "
     SQL = SQL & " FROM Passenger INNER JOIN "
     SQL = SQL & " Address ON Passenger.HomeAddressID = Address.AddressID INNER JOIN "
     SQL = SQL & " Vanpool ON Passenger.VanpoolID = Vanpool.VanpoolID "
     SQL = SQL & " WHERE (Passenger.Active = 1) AND (Address.Active = 1) AND (Vanpool.Active = 1) "
     SQL = SQL & " AND Address.City like '%" & CityKeywords & "%' "
     SQL = SQL & " ORDER BY Address.City"


	Set RS = Server.CreateObject("ADODB.recordset")
	RS.open SQL, DbConnection, 3,3
    RS.MoveFirst
    While Not RS.EOF
		Response.Write(RS("city") & vbCrLf) 
		RS.MoveNext
	Wend 
    RS.Close
	Set RS = Nothing
    Set DbConnection = Nothing
	Response.End
End Function
%>
<script type="text/javascript">
    $(document).ready(function () {
        $("#TxtOriginCity").autocomplete("SearchCity.asp");
    });
</script>

Open in new window

9-9-2011-3-40-07-PM.pdf
0
Comment
Question by:Webboy2008
2 Comments
 
LVL 10

Expert Comment

by:P1ST0LPETE
ID: 36515253
I'm looking at your screen shot now.  Your problem doesn't look to be a jQuery issue.  It looks like you are returning blank data from your database.

Google Chrome is a good browser to use when developing websites, as it offers a lot of good developer tools.  While using Chrome, navigate to your page that has the autocomplete plugin on it.  Hit the F12 key to open up Chromes developer tools, and then click on the network tab of the developer tools.  Then start typing in the textbox with the autocomplete attached to it to initiate the ajax, and then you should be able to see the ajax POST's that are being made in Chromes developer tools.  Expand one of the ajax POST and examine the data that is being returned to see what data you are getting back from the server.
0
 
LVL 9

Accepted Solution

by:
djpazza earned 500 total points
ID: 36522109
I agree it looks like you have empty data in the database.  Try the attached code I have added a loop to check for a value.
<%
Function AjaxSearchCity(CityKeywords,DbConnection)
    'SQL = "select distinct city from address where city like '%" & CityKeywords & "%' order by city asc"
     SQL = " SELECT DISTINCT Address.City, Vanpool.Active "
     SQL = SQL & " FROM Passenger INNER JOIN "
     SQL = SQL & " Address ON Passenger.HomeAddressID = Address.AddressID INNER JOIN "
     SQL = SQL & " Vanpool ON Passenger.VanpoolID = Vanpool.VanpoolID "
     SQL = SQL & " WHERE (Passenger.Active = 1) AND (Address.Active = 1) AND (Vanpool.Active = 1) "
     SQL = SQL & " AND Address.City like '%" & CityKeywords & "%' "
     SQL = SQL & " ORDER BY Address.City"


	Set RS = Server.CreateObject("ADODB.recordset")
	RS.open SQL, DbConnection, 3,3
    RS.MoveFirst
    While Not RS.EOF
               if RS("city") <>"" then   
		Response.Write(RS("city") & vbCrLf)
               end if
		RS.MoveNext
	Wend 
    RS.Close
	Set RS = Nothing
    Set DbConnection = Nothing
	Response.End
End Function
%>
<script type="text/javascript">
    $(document).ready(function () {
        $("#TxtOriginCity").autocomplete("SearchCity.asp");
    });
</script>

Open in new window

0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question