Question: I have used `JavaScript` to color code my SharePoint calendar.

In that script, I have to call method `ColourCalendar()` when "more items" is clicked.

```
$('.ms-cal-nav').attr('href', 'javascript:ColourCalendar();'); 

```

The above line is working only for "n more items" link. But when I click on the triangle like symbol next to "more items" link, it is not working.[Attached image](http://i.stack.imgur.com/JTs6g.png)

1 more item

How can I call this method when the image in `href` is clicked?

Answer: 
`$.getJSON` is an ajax request and is asynchrounous. It doesn't return data , it returns a promise.

You need to consume the response data in a success or done callback

```
$.getJSON("geojson/com/14001.json", function(responseData){
   // do something with responseData
});

// OR
 $.getJSON("geojson/com/14001.json").done(function(responseData){
   // do something with responseData
});

```

See [$.getJSON docs](http://api.jquery.com/jQuery.getJSON/)
Shouldn't it be like this

```
var obj_fail = {};
$.getJSON("geojson/com/14001.json")
 .done(function(data){
    obj_fail = data;
 });

```

Hope this helps!