테스트 사이트 - 개발 중인 베타 버전입니다

ajax 사용시 팝업이 차단되는 경우 질문입니다. 채택완료

동태태 8년 전 조회 2,375

///////////////go.php

 

<html>

<head>

<title>연습</title>

 <script src="http://code.jquery.com/jquery-1.11.1.min.js" style="color: rgb(0, 0, 0);">http://code.jquery.com/jquery-1.11.1.min.js"></script>

 <script>

  $(document).ready(function(){

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

 

  var query = { subject : $("#subject").val(), content : $("#content").val(), writer : $("#writer").val(), insdt : $("#insdt").val() };

 

 $.ajax({

type: "POST",

url: "test01.php",

data: query,

success: function(data){

if(data == 1){

$("#f1").attr("action", "test02.php");

$("#f1").attr("target","sun_test");

$("#f1").submit();

}// end if

}// end success

  });

  });

});

</script>

</head>

<body>

<form name="f1" id="f1">

이름:<input type="text" name="subject" id="subject"/><br />

내용:<input type="text" name="content" id="content"/><br />

글쓴이:<input type="text" name="writer" id="writer"/><br />

입력:<input type="text" name="insdt" id="insdt"/><br />

</form>

<input type="button" style="button" value="확인" id="button" />

</body>

</html>

 

//////////////////test01.php

 

<?php

echo 1;

?>

 

////////////////test02.php

 

<?php

 

echo "안녕하세요";

?>

 

 

위의 3가지의 php 파일이 있는데요. go.php로 ajax를 호출하면 브라우저에서 팝업 차단된다고 뜨거든요?  어떻게 하면 브라우저 차단이 안뜨고 잘 될수 있을까요? 알려 주시면 정말 감사하겠습니다.

 

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트
플라이
8년 전

타겟을 sun_test라는 곳이 없기에 새창으로 연결 되어 있어서 그렇게 뜨는거 같은데요

 

iframe 이나 자바스크립트로 window.open을 처리해서 하면 어떨까 싶기도 합니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

동태태
8년 전
새창으로 열어야 합니다. ㅠㅠ ajax를 안쓰면 팝업 차단이 안걸리는데... ajax를 써야 하는 상황이라 죽을 맛이네요 ㅎㅎ

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인