채택완료

ajax 페이지에서 스크립트 실행하는법..

2018-11-16 (금) 22:08:42 4,302

---- wirte.php ----

$.ajax({

 url : "./ajax.write.php",

 type : "post",

 data: $(form).serialize(),

 success: function(result) {

   alert('test');

 }

})

---- ajax.write.php ----

<form name="formname" action="test.com/z.php">

<input type="hidden" name="test" value="test">

</form>

<script>

document.formname.submit();

</script>

ajax.write.php 에 있는

폼을 또 서브밋하려고 하는데 스크립트가 안먹는거같네요

어떻게 해야할까요ㅜㅜ

|

답변 2개 / 댓글 2개

채택된 답변
+20 포인트

페이지를 Load 해야 실행되는데 음..

간단하게 하시려면 eval 을 사용하세요

document.formname.submit(); 이걸 result 값으로 보내고

eval(result);

action=http://test.com/z.php<------- 수정

답변에 대한 댓글 2개

질문글에 대한 내용을 이해못하신것같습니다ㅜ
action에서 도메인에 http가 없으면 당근 실행 안되니 수정하라는 말입니다
http가 안 붙으면 test.com이라는 폴더에서 z.php를 찾습니다

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