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

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

QA

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

답변 1

본문

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

 

<html>

<head>

<title>연습</title>

 <script src="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

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

 

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

답변을 작성하시기 전에 로그인 해주세요.
전체 2
© SIRSOFT
현재 페이지 제일 처음으로