이 함수로 아약스로 변수를 보낼 수는 없지만 PHP로 직접 보내고 mysql에 삽입 할 수 있습니다.아약스로 phars에 vars 보내기
나는 그것을 PHP로 테스트 해본 결과 전형적으로 php 파일에 폼 액션을 보내고 잘 동작한다. 내가 뭘 놓치고 있는지 모르겠다. 미리 감사드립니다. 안부 인사
<form class="largeform" id="editform" name="editform" accept-charset="utf-8" action="" onsubmit="enviarDatosEmpleado(); return false">
어떤 생각이 있으십니까? // 자바 스크립트 문서 기능 objetoAjax() {
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function enviarDatos(){
//donde se mostrará lo resultados
divresultado = document.getElementById('resultado');
//valores de los inputs
post_title=document.editform.post_title.value;
post_metad=document.editform.post_metad.value;
post_metak=document.editform.post_metak.value;
post_special=document.editform.post_special.value;
post_content=document.editform.post_content.value;
post_private=document.editform.post_private.value;
post_parent=document.editform.post_parent.value;
post_template=document.editform.post_template.value;
post_id=document.editform.post_id.value;
post_menu=document.editform.post_menu.value;
post_menu_order=document.editform.post_menu_order.value;
//instanciamos el objetoAjax
ajax=objetoAjax();
//uso del medotod POST
//archivo que realizará la operacion
//registro.php
ajax.open("POST", "insert.php",true);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
//mostrar resultados en esta capa
divresultado.innerHTML = ajax.responseText
divresultado.innerHTML = "ok";
divresultado.style.display="block";
//llamar a funcion para limpiar los inputs
LimpiarCampos();
}
}
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
//enviando los valores
ajax.send ("post_title="+post_title+"&post_metad="+post_metad+"&post_metak="+post_metak+"&post_special="+post_special+"&post_content="+post_content+"&post_private="+post_private+"&post_parent="+post_parent+"&post_template="+post_template+"&post_id="+post_id+"&post_menu="+post_menu+"&post_menu_order="+post_menu_order)
// ajax.send("nombres="+nom+"&departamento="+dep+"&sueldo="+suel)
}
충분하지 jQuery –
jQuery 또는 mootools 또는 Prototype을 사용하십시오. 당신은 그들을 절실히 필요로합니다. – FatalError
@webarto moar jquery가 필요합니다. – Lusitanian