I am trying to send a JSON Array to my fullCalendar which locate on gamesetting.jsp. the json array object has been test through console and
It has showing the cerrect answer.then I tried $("#calendar").fullCalendar( 'addEventSource', source ), chrome give back a 406 error and want the response asThe resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.
@RequestMapping ( method=RequestMethod.GET ,produces={"application/json; charset=UTF-8"})
public @ResponseBody JSONObject returnGames(GameVO gameVo,HttpServletResponse response) throws IOException{
GameService gService= new GameService(gameDao);
List<GameVO> games= gService.select(gameVo);
JSONArray jsonArray = new JSONArray();
JSONObject jsonObj =null;
for(GameVO game:games){
jsonObj = new JSONObject();
jsonObj.put("game_no", game.getGame_sd());
jsonObj.put("game_name", game.getGame_name());
jsonObj.put("game_time", game.getGame_time());
jsonArray.put(jsonObj);
}
System.out.println("jsonArray: "+jsonArray);
response.setHeader("Accept", "application/json");
return jsonObj;
}
shown in console
jsonArray: [{"game_name":"A vs B","game_time":"2015-05-20 00:00:00.0","game_no":1}]
and this is my JavaScript code
$(document).ready(function() {
$('#calendar').fullCalendar({
customButtons: {
myCustomButton: {
text: 'custom!',
click: function getGames(e){
var games;
var url='selectAllGames.controller';
if (getGames){
$.getJSON(url,null,
function(){$("#calendar").fullCalendar( 'addEventSource',url )})
;}
console.log(e);
}
}
},
I really have no clue what's wrong...