답변 3개
config.form.update 에선 echo json_encode($var); 을 이용해서 json 형태로 뽑아줄수있구요
config.form.update.php
</span></p><p><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"><?php</span></p><p style="margin-left: 40px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);">$array = array('test'=>1,'test2'=>2);</span></p><p style="margin-left: 40px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);">echo json_encode($array);</span></p><p><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);">?></span></p><p><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);">
사용페이지
</span></p><p><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"><script type="text/javascript"> </span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> var formData = jQuery('#form_test').serializeArray(); </span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> var f = document.createElement('form'); </span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;">// <span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);">g=config&pmode=config.form.update 여기서 g/pmode 는 이미 form_test 라는 폼에 있으리라는 전제조건 하입니다.</span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> $("#bt_test").on('click',function () { </span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> $.ajax({ </span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> url: "/page/index.php", </span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> type: "POST", </span></p><p> dataType:'json',<br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> data: formData, </span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> success: function (r) { </span></p><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> console.log(r)</span><span style="background-color: rgb(247, 247, 247); color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;">;</span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> console.log(r.test)</span><span style="background-color: rgb(247, 247, 247); color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;">;</span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> console.log(r.test2)</span><span style="background-color: rgb(247, 247, 247); color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;">;</span><p><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> }, </span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> error: function (jqXHR, textStatus, errorThrown) { </span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> } </span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> }) </span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> }); </span><br style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px;"><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> </script> </span><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);"> </span></p><p><span style="color: rgb(51, 51, 51); font-family: 돋움, Dotum, sans-serif; font-size: 12px; background-color: rgb(247, 247, 247);">
댓글을 작성하려면 로그인이 필요합니다.
데이터 받는것은 $_POST 받는 방식으로 받으면 되고요
데이터 전달하는 ajax 방식은
참고 주소를 보시면 될듯 합니다.
http://findfun.tistory.com/400">http://findfun.tistory.com/400
답변에 대한 댓글 3개
page/?g=config&pmode=config.form.update
이건 get 방식으로 파라미터 전달도 사용하고 post도 사용하려는 부분처럼 보여지고요
전달 페이지가 이런 방식으로 전달이 되면 안되고요 별도 페이지로 해서 전달하셔서 처리하셔야 할겁니다.
어떤식으로 호출을 해야되나요?
댓글을 작성하려면 로그인이 필요합니다.
답변에 대한 댓글 1개
var formData = jQuery('#form_test').serializeArray();
var f = document.createElement('form');
$("#bt_test").on('click',function () {
$.ajax({
url: "/page/?g=config&pmode=config.form.update",
type: "POST",
data: formData,
success: function (formData, textStatus, jqXHR) {
location.href = "<?php echo G5_URL?>/page/?g=config&pmode=config.form.update";
},
error: function (jqXHR, textStatus, errorThrown) {
}
})
});
</script>
내용인데 그리고 나서 config.form.update 페이지를 호출해서 post값을 받아서 사용하고싶습니다.
formdata안에는 cf_title 등이 있습니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인