Solved

jquery / classic asp

Posted on 2011-09-09
2
1,639 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
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.…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

751 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