Solved

jquery / classic asp

Posted on 2011-09-09
2
1,630 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now