-
JavaScript) 자바스크립트에서 Form데이터 POST전송하기Programming/Etc. 2011. 7. 27. 16:23반응형출처 : http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit
function post_to_url(path, params, method) { method = method || "post"; // Set method to post by default, if not specified. // The rest of this code assumes you are not using a library. // It can be made less wordy if you use one. var form = document.createElement("form"); form.setAttribute("method", method); form.setAttribute("action", path); for(var key in params) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", key); hiddenField.setAttribute("value", params[key]); form.appendChild(hiddenField); } document.body.appendChild(form); form.submit(); }
// 사용예) 다음 로그인 post_to_url("https://logins.daum.net/accounts/login.do", {"id":"아이디", "pw":"비밀번호"});
반응형'Programming > Etc.' 카테고리의 다른 글
[PHP/CodeIgniter] date(): It is not safe to rely on the system's timezone settings in CodeIgniter (0) 2014.08.17 JavaScript) 로또번호 생성기 소스 ( 자바스크립트 ) (0) 2008.01.01 [DSApi WebServer Filter] AllocMem으로 할당한 메모리는 언제까지 유지될까? (0) 2007.12.06