Last active
August 29, 2015 14:06
-
-
Save RemeJuan/64409b9bf6866fe5edfe to your computer and use it in GitHub Desktop.
AJAX search query returning JSON data from DB to populate UL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Function to handle database search and process results | |
function getCustomers(searchQuery) { | |
$.ajax({ | |
type: 'POST', | |
url: '/com/cfcs/SearchServices.cfc?method=searchCustomerByName&customerName=' + searchQuery + '&returnFormat=json', | |
datatype: 'json', | |
cache: false, | |
success: function(response) | |
{ | |
var searchResults = response.DATA, | |
destination = $("#searchResults"), | |
str = ''; | |
destination.empty(); | |
if (searchResults.length === 0) { | |
} | |
for (var x = 0; x < searchResults.length; x++) | |
{ | |
str += ("<li data-id=" + searchResults[x][0] + ">" + searchResults[x][1] + "</li>"); | |
} | |
destination.html(str).slideDown(250); | |
$('#addCustomer').removeClass('loading'); | |
updateArray(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment