$(document).ready(function(){ $("button").click(function() { var htmlFrom=$("#from").val(); var htmlTo=$("#to").val(); $("#ResultTitle").hide(); $.get ("myHTML") departure:htmlFrom, destination:htmlTo }, function(data,status) { parse(data,status,htmlFrom,htmlTo); }); });
});
function parse(data,status,htmlFrom,htmlTo) { if ((htmlFrom.length >0) && (htmlTo.length >0)) { if (data.restResponse.data.length==0) { $(".element").html("Invalid Departure/Destination"); } else { display(data); } } }