ajax 중복체크 질문 채택완료
아기새
8년 전
조회 8,878
test1.php
</p><p><span class="teach_type" data-idx="2911">test1</span>
</p><p><span class="teach_type" data-idx="2912">test2</span></p><p><span class="teach_type" data-idx="2912">test3</span></p><p>
test2.php
</p><p><script type="text/javascript">
$(".teach_c").click(function(){
tuid = $(this).attr('data-idx');
$.ajax({
url: "/ajax/teach.php",
type: "post",
dataType: "json",
data:{uid:tuid},
success: function(data){
if(opener.$('.teach_type').attr('data-idx') == tuid){
alert('이미 추가되어있습니다.');
} else {
opener.$('.teach_name').append(data.area);
}
}
})
return false;
});
</script>
</p><p>
</p><p>
db에 넣지않고 체크를 하려고하고있는데요
ajax success하면 append로
test1
test2
test3
하나하나씩 추가가됩니다.
근데 data-idx가 같은값이면 append가 되지않게하려고합니다..
도와주세요.ㅜ
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
답변을 작성하려면 로그인이 필요합니다.
로그인