ajax

ajax

QA

ajax

본문

ajax로 css나 class도 비동기로 변경할수있나요?

php로 값을 받아서 그 값이 0일때 css의 display를 none이나 block 또는

class ab추가를 비동기식으로 하고싶은데 방법이 있을까요?? 궁금합니다 ~~ ㅠㅠ 구글링해도 잘안나오내요..

이 질문에 댓글 쓰기 :

답변 2


$.ajax({
    url: "test.php",
    type: "post"
}).done(function(data) {
    if (data == "0") {
        $('#d_test').addClass('ab');
        //$('#d_test').show();
        //$('#d_test').hide();
    }
});

                'success': function(data) {
                    if (data.status == 200) {
                        modal.style.display = 'none';
                        modal.classList.toggle('show');
                        return false;
                    } else {
                        modal.style.display = 'none';
                        modal.classList.toggle('show');
                        return false;
                    }
                }

 

위와 같이 성공 했을 때 상태 값에 따라서 css 를 변경 하시면 됩니다....

$.ajax ({
  url : "url",
  type : "GET",
  async : true, 
  cache : true, 
  timeout : 3000,
  data  : {key : value},
  processData : true,
  contentType : "application/json",
  dataType    : "json",ㅣ
  beforeSend  : function () {
   
  },
  success : function(data) {
    if (data.status == 200) { modal.style.display = 'none'; modal.classList.toggle('show'); return false; } else { modal.style.display = 'none'; modal.classList.toggle('show'); return false; }
  },
  error : function(xhr, status, error) {
   
  },
 
  }
});

여기서 url을 따로 넣어야 돼는거 아닌가용?

답변을 작성하시기 전에 로그인 해주세요.
전체 123,535 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT