Well, I would like to know if there is any possibility of showing a JSON list from a URL and in the same url they generate the following values: nmConveniado , strong , ListEndereco .
I tried to use the following script but did not succeed:
<script>
// Users data in json format
var userData = URL: "http://url.com/arquivo.json" };
// user's input for search
var searchVal = '';
$(function(){
// if text box value is not null, then darken reset icon
$(".slinput input").keyup(function(){
var val = $(this).val();
if(val.length > 0) {
$(this).parent().find(".right-icon").css('color','#555');
} else {
$(this).parent().find(".right-icon").css('color','#ccc');
}
});
// if user click on reset icon, clear text field
$(".slinput .right-icon").click(function(){
$(this).parent().find("input").val('');
$(this).css('color','#ccc');
loadData(userData);
});
loadData(userData);
});
// Displaying Information to Users
function loadData(data) {
var htmlData = '';
$.each(data, function(index, val){
htmlData += '<div class="media user">'+
' <div class="media-left">'+
' <a href="#">'+
' <img class="media-object" src="'+val.listaImagem+'" alt="...">'+
' </a>'+
' </div>'+
' <div class="media-body">'+
' <h4 class="media-heading">'+val.nmConveniado+'</h4>'+
' '+val.place+
' </div>'+
'</div>';
});
$("#users").html(htmlData);
}
// Search users data based input search keyword
function searchUsers() {
var val = $("#searchInput").val();
if(val == searchVal) {
return;
} else {
searchVal = val;
var searchResults = {};
searchResults = [];
$.each(userData, function(i, v) {
if (v.nmConveniado.toLowerCase().indexOf(val) != -1) {
searchResults.push(v);
}
});
loadData(searchResults);
}
}
</script>
In the same file I will try to filter the list by name, city, category.