After click a link, will trigger ajax require to /material/materialPrintajax, which will return JSON format data, and the returned JSON data has been verified through http://jsonlint.com/, the website tell me my return JSON is valid. But as I come across,
console.log(jsonResult); always return null in firebug console.
Former solution in stackoverflow does not solve this, as I have refered:
http://stackoverflow.com/questions/6465468/why-parsejson-returns-null
http://stackoverflow.com/questions/8575479/parsing-json-string-returns-null
and so on..
Here are my codes:
$.ajax({
url : $.att.config.BASE_URL + "/material/materialPrintajax",
type : "POST",
dataType : "json",
data: {
"choosenCourse" : choosenCourse,
"choosenDate" : choosenDate,
"choosenElCode" : choosenElCode
},
//read json result & display print data in HTML
success : function(re){
console.log('good!!',re);
jsonResult = jQuery.parseJSON(re);
console.log(jsonResult);
},
error :function(re) {
//eg. if return data is not json format
console.log('error!!',re);
}
});
in case you need, here is my returned JSON (re):
{"COOKING":{"A":{"0":{"CLASS_MENU_SYMBOL":"A","STAFF_ID":"3010120001","LAST_NAME_KANJI":"\u6817\u7530","FIRST_NAME_KANJI":"\u6607","STAFF_START_TIME":"09:00","STAFF_END_TIME":"10:00","COURSE_ID":"0","COURSE_NAME_JP":"\u6599\u7406","RESERVE_COUNT":1},"RESERVE_TOTAL":3,"1":{"CLASS_MENU_SYMBOL":"A","STAFF_ID":"3010120012","LAST_NAME_KANJI":"\u9648","FIRST_NAME_KANJI":"\u6167\u5a77","STAFF_START_TIME":"21:00","STAFF_END_TIME":"22:00","COURSE_ID":"0","COURSE_NAME_JP":"\u6599\u7406","RESERVE_COUNT":2}},"B":{"0":{"CLASS_MENU_SYMBOL":"B","STAFF_ID":"3010120001","LAST_NAME_KANJI":"\u6817\u7530","FIRST_NAME_KANJI":"\u6607","STAFF_START_TIME":"13:00","STAFF_END_TIME":"14:00","COURSE_ID":"0","COURSE_NAME_JP":"\u6599\u7406","RESERVE_COUNT":1},"RESERVE_TOTAL":1}},"BREAD":{"B7":{"0":{"CLASS_MENU_SYMBOL":"B7","STAFF_ID":"3010120010","LAST_NAME_KANJI":"\u738b","FIRST_NAME_KANJI":"\u5a77","STAFF_START_TIME":"15:00","STAFF_END_TIME":"17:00","COURSE_ID":"1","COURSE_NAME_JP":"\u9762\u5305","RESERVE_COUNT":1},"RESERVE_TOTAL":1},"B1":{"0":{"CLASS_MENU_SYMBOL":"B1","STAFF_ID":"3010120010","LAST_NAME_KANJI":"\u738b","FIRST_NAME_KANJI":"\u5a77","STAFF_START_TIME":"15:00","STAFF_END_TIME":"17:00","COURSE_ID":"1","COURSE_NAME_JP":"\u9762\u5305","RESERVE_COUNT":1},"RESERVE_TOTAL":1}},"CAKE":{"12":{"0":{"CLASS_MENU_SYMBOL":"12","STAFF_ID":"3010120012","LAST_NAME_KANJI":"\u9648","FIRST_NAME_KANJI":"\u6167\u5a77","STAFF_START_TIME":"09:00","STAFF_END_TIME":"11:00","COURSE_ID":"2","COURSE_NAME_JP":"\u86cb\u7cd5","RESERVE_COUNT":2},"RESERVE_TOTAL":2}}}