웹프로그래밍

Global It Leader!!


jQuery


 
 

JSON과 ajax 이용 시 화면이 넘어가는 에러 해결방법

페이지 정보

작성자 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 1,282회 작성일 22-03-27 03:03

본문

[문제]

로그인 시 아이디나 비밀번호가 틀렸을 때 알림만 뜨고 화면은 머물러야 하는데 자꾸 화면이 넘어갔다.

(원래 계획대로라면 JSON과 azax를 이용해 화면은 그대로인 채 정보만 주고 받아야 하는 상황)

[해결]

jsp파일의 <form> 과 <button>에 문제가 있었던 거였음.

<form> 안에 <button>이 있으면 액션이 두 번처리 되는 현상 발생.

---> <button>을 <form>밖으로 빼면서 해결함.


<div class="box_grid">

<form name="frm1" id="frm1" autocomplete="off">

<input type="hidden" name="flag" value="top">

<div class="write_div">

<label for="wr7_01" class="sound_only">유권자수</label>

<input type="text" name="wr7_01" value="<?php echo $wr7_01; ?>" id="wr7_01" class="frm_input half_input" placeholder="지역 유권자수">


<label for="wr7_02" class="sound_only">투표자수</label>

<input type="text" name="wr7_02" value="<?php echo $wr7_02; ?>" id="wr7_02" class="frm_input half_input" placeholder="지역 투표자수">

    </div>

</form>

<div class="btn_confirm write_div">

        <button type="submit" id="btn_send1" accesskey="s" class="btn_medium red"><i class="fas fa-check"></i> 자료전송</button>

    </div>

</div>


<script>

 

        $("#btn_send1").click(function () {


var targetForm = $("#frm1:input");

         

$.each(targetForm, function(index, elem){

$(this).val($(this).val().replace(/,/g, ''));

});

 

var param = $("form[name=frm1]").serialize();

$.ajax({

url: '<?php echo $content_skin_url;?>/content.write.php',

type:"POST",

data : param,

success:function(result){

alert(result);

},

error:function(request,status,error){

alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);

}

});

        });


</script>

댓글목록

등록된 댓글이 없습니다.

전체 142
게시물 검색
jQuery 목록
번호 제목 글쓴이 조회 날짜
142 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 414 07-06
141 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 639 01-05
140 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 734 12-07
139 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1256 03-31
138 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1260 03-28
137 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1249 03-27
136 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1711 03-27
135 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1241 03-27
열람중 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1283 03-27
133 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1558 03-26
132 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1266 03-26
131 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1417 03-26
130 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2725 03-26
129 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1899 03-26
128 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1460 03-26
127 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1634 03-26
126 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1883 03-26
125 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1290 03-26
124 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1213 03-26
123 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1376 03-26