Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

jquery / classic asp

Posted on 2011-09-09
2
Medium Priority
?
1,673 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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…
Suggested Courses

885 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