Solved

jquery / classic asp

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

896 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

17 Experts available now in Live!

Get 1:1 Help Now