jQuery(2)
-
jQuery를 사용하여 로딩 화면을 표시하고, AJAX 요청을 보내고 응답을 받는 동안 로딩 화면을 유지하는 코드 예시입니다.
/* 로딩 화면 스타일 */ #loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 9999; display: none; } .spinner { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); border: 4px solid rgba(255, 255, 255, 0.3); border-top: 4px solid #ffffff; border-radius: 50%; width: 32px; height: 32px; animation: spin 1s linea..
2023.04.07 -
jQuery를 사용하여 AJAX 요청 및 JSON 응답 데이터 처리하는 코드 예시입니다.
// AJAX 요청 생성 $.ajax({ url: "example.com/api/data", method: "GET", dataType: "json", // 응답 데이터 형식 설정 success: function(responseData) { // 응답 데이터 처리 console.log(responseData); // 응답 데이터 처리 코드 }, error: function(xhr, status, error) { // 에러 처리 console.log("Error: " + error); } }); jQuery의 $.ajax() 함수를 사용하여 AJAX 요청을 생성하고 dataType: "json"으로 응답 데이터 형식을 JSON으로 설정합니다. 응답 데이터를 처리하기 위해 success 콜백 함수를 사용하며..
2023.04.07