Obtenga solicitud de AJAX para JavaScript/JS:
<script type = "text/javaScript">/* create xmlhttprequest object*/var xmlhttp; función getxmlhttpObject () {if (window.xmlhttprequest) {// código para IE7+, Firefox, Chrome, Opera, Safari XMLHTTP = nuevo xmlhttprequest (); } else {// código para IE6, IE5 xmlhttp = new ActiveXObject ("Microsoft.xmlhttp"); } return xmlhttp; } // ----------------------- // function getLabelSget () {xmlhttp = getxmlhttpobject (); if (xmlhttp == null) {alert ('su navegador no admite AJAX!'); devolver; } var id = document.getElementById ('id'). valor; var url = "http://www.leefrom.com?id="+id+"& t/"+math.random (); xmlhttp.open ("get", url, verdadero); xmlhttp.onreadyStateChange = favork; // Después de enviar el evento, se recibió el mensaje. La función de llamada xmlhttp.send (); } function getokget () {if (xmlhttp.readyState == 1 || xmlhttp.readyState == 2 || xmlhttp.readyState == 3) {// Local Semunt: Carging} if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {var d = xmlhttp.esponsetext; // El procesamiento devuelve el resultado}} </script>Solicitud de publicación para AJAX para JavaScript/JS:
<script type = "text/javaScript">/* create xmlhttprequest object*/var xmlhttp; función getxmlhttpObject () {if (window.xmlhttprequest) {// código para IE7+, Firefox, Chrome, Opera, Safari XMLHTTP = nuevo xmlhttprequest (); } else {// código para IE6, IE5 xmlhttp = new ActiveXObject ("Microsoft.xmlhttp"); } return xmlhttp; } // ----------------------- // function getLabelsPost () {xmlhttp = getxmlhttpobject (); if (xmlhttp == null) {alert ('su navegador no admite AJAX!'); devolver; } var url = "http://www.lifefrom.com/t/"+math.random (); xmlhttp.open ("post", url, verdadero); xmlhttp.setRequestHeader ("Content-type", "Application/x-www-form-urlencoded"); xmlhttp.send (); xmlhttp.onreadyStateChange = getLabelSok; // Después de enviar el evento, se recibió el mensaje, llamando a la función} function getokPost () {if (xmlhttp.readystate == 1 || xmlhttp.readyState == 2 || xmlhttp.readystate == 3) {// rápido: aviso de carga/aviso/procesamiento/procesamiento/procesamiento/procesamiento/procesamiento/procesamiento}} (xmlhttp.readyState == 4 && xmlhttp.status == 200) {var d = xmlhttp.Responsetext; // Valor de retorno // Valor de retorno de procesamiento}} </script>Nota: XMLHTTPREQUEST es la base de AJAX. Al crear objetos xmlhttprequest, debe estar en la misma etiqueta '<script> </script>' como el método AJAX que escribió. De lo contrario, la solicitud AJAX se equivocará y los datos no se devolverán. JavaScript/JS AJAX POST/GET Solicitud.
La breve discusión anterior de JS Native Ajax, Get and Post es todo el contenido que comparto con ustedes. Espero que pueda darle una referencia y espero que pueda apoyar más a Wulin.com.