jQuery(document).ready(function($){
	$(document).on("click", "#load-more-btn", function(e) {
		var btn = $(this);
		var args = $(btn).data("args");
		$(btn).html("<em>Loading...</em>");
		var loader = document.createElement("img");
		loader.src = "app/images/ajax-loader.gif";
		loader.width = 100;
		loader.style.display = "block";
		loader.style.margin = "auto";
		$("#display-search-result").append(loader);
		$.ajax({
			type: 'POST',
		    url: "app/includes/ajax.php",
		    data: {action: "load_more_search_result", args: args},
		}).done(function(data){
			try {
				data = JSON.parse(data);
				$(loader).remove();
				if(data.continue) {
					$("#display-search-result").append(data.html);
					$(btn).html("Load More Results");
				} else {
					$(btn).html(data.html).click(function(e){
						return false
					});
				}
			}
			catch(err) {
				console.log(data);
				console.log(err);
			}
			finally {
				console.log(data);
			}
		}).fail(function(e){

		})
	})
})