ajax 채택완료
망공
2년 전
조회 1,857
ajax로 css나 class도 비동기로 변경할수있나요?
php로 값을 받아서 그 값이 0일때 css의 display를 none이나 block 또는
class ab추가를 비동기식으로 하고싶은데 방법이 있을까요?? 궁금합니다 ~~ ㅠㅠ 구글링해도 잘안나오내요..
댓글을 작성하려면 로그인이 필요합니다.
답변 2개
채택된 답변
+20 포인트
마르스컴퍼니
Expert
2년 전
</p>
<p>$.ajax({
url: "test.php",
type: "post"
}).done(function(data) {
if (data == "0") {
$('#d_test').addClass('ab');</p>
<p> //$('#d_test').show();</p>
<p> //$('#d_test').hide();</p>
<p> }
});</p>
<p>
로그인 후 평가할 수 있습니다
답변에 대한 댓글 1개
�
망공
2년 전
호오.. 감사합니다 뭔가.. count라는 class에 ab를 땟다 붙였다 비동기식으로 해보려고했으나 작동은돼는데 동기를해야만이 작동을하내요 ㅠㅠ
댓글을 작성하려면 로그인이 필요합니다.
2년 전
</p>
<p> '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;
}
}</p>
<p>
위와 같이 성공 했을 때 상태 값에 따라서 css 를 변경 하시면 됩니다....
로그인 후 평가할 수 있습니다
답변에 대한 댓글 5개
�
망공
2년 전
이방식은 따로 url을 안불러오고도 사용할수가있나요? Data.status가 어떤값을 가지고있는건가요?
�
망공
2년 전
응답바디 응답코드인거같은데.. 왜 200의값을 가지고있는건가욤? 타임아웃 시간인건가요?
�
망공
2년 전
$.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을 따로 넣어야 돼는거 아닌가용?
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을 따로 넣어야 돼는거 아닌가용?
�
설국열차
2년 전
$data = array(
'status' => 400,
'msg'=>'회원만 접근 가능합니다.'
);
접속한 ajax 파일에서 위와 같이 status 변수에 값을 넣어서 넘겨 줘야 합니다.
'status' => 400,
'msg'=>'회원만 접근 가능합니다.'
);
접속한 ajax 파일에서 위와 같이 status 변수에 값을 넣어서 넘겨 줘야 합니다.
�
망공
2년 전
감사합니다..! 덕분에 ajax를 쓰는방법을 정확히 이해하게 돼었습니다 !
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인