I am not sure whether this is a silly question… I am trying to sort a JSON array using jQuery click event. The following is a simplified html code which I thought should work:
<SCRIPT type='text/javascript'>
function results(json) {
// display unsorted results in $ ('#results')
}
$ ('#sort').click(function (json) {
// sort and display results in $ ('#results')
});
var query = some_query;
var json = new Object();
$ .getJSON(query, results);
</SCRIPT>
<A href='javascript:void(0)' id='sort'>Sort</A>
<DIV id='results'></DIV>
I am getting no response upon clicking the Sort link. When I replace the sort function with alert(json), I get a json is undefined error. Am I missing out something here?