본문 바로가기

Javascript4

콜백, 왜 써야 되는 건데? A callback is merely a defined action that occurs in response to something. A callback can be set to fire at the completion of an event handler The function that gets fired when AJAX completes.... that is a callback Mentally rename them functionToRunWhenYoureDone. Example: http.get(url, callback) basically says: hey http module, get me this url, oh and also here's a function you should run when .. 2024. 12. 10.
Javascript - 프로토타입 메모리에 남아있는 원형 object. 인스턴스에 프로퍼티를 정의하면 날라가지만 프로토타입에 프로퍼티를 저장하면 얘를 상속한 다른 object들이 다 갖고있게 됨  function Bike(gears, startGear) { this.gears = gears; this.currentGear = startGear;}Bike.prototype.changeGear = function(direction, changeBy) { if (direction === 'up') { this.currentGear += changeBy; } else { this.currentGear -= changeBy; }}This way every object created from Bike inherits the ch.. 2024. 12. 6.
JS Object를 JSON.stringify()로 보내고 스프링 컨트롤러에서 HashMap으로 받기 //컨트롤러@PostMapping("/list/sentence")public List list(@RequestBody HashMap param){int page=(int)param.get("page");int size=(int)param.get("size");List sentenceList= service.findSentenceByPageable(page,size);return sentenceList;}//objectvar param={ page:0, size:5 } //ajax 호출 부분$.ajax({ type:'POST', url:'/list/sentence', dataType:'json', data:JSON.stringify(param), contentType:"applicati.. 2020. 12. 21.
js - 스크롤 바닥에 닿으면 목록 더 불러오기 //처음화면if($("body").height()=$(document).height()-$(window).height()){ param.page++;// custom variable getList(); // custom function } }); 2020. 12. 21.