Código AJAX
Código:
página 1function ajaxShow(str, gopage, loadsec, idform){ var xmlHttp; xmlHttp=GetXmlHttpObject(); if (xmlHttp==null){ alert ("Su navegador web no maneja AJAX!"); return; } //Add passed Values var url = gopage; //If variables are set if (str != ''){ url = url + '?' + str + '&sid=' + Math.random(); } //If a form is set else if (idform != ''){ //var test = document.getElementById(idform).elements; //alert(test.length); var pineapple = document.getElementById(idform).elements; url = url + '?'; for (var i = 0; i < pineapple.length; i++){ //check for first var if (i != 0) { url = url + '&'; } //check for checkboxes if ((pineapple[i].type == 'checkbox') && (pineapple[i].checked == false)){ url = url + pineapple[i].name + '='; } else { url = url + pineapple[i].name + '=' + pineapple[i].value; } } url = url + '&sid=' + Math.random(); } //If nothing is set else { url = url + '?sid=' + Math.random(); } document.getElementById(loadsec).innerHTML= '<div align="center"><img src="images/layout/loading.gif" /></div>'; xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET", url, true); xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); //alert(url); return; xmlHttp.send(''); function stateChanged(){ if (xmlHttp.readyState==4){ document.getElementById(loadsec).innerHTML=xmlHttp.responseText; //alert(xmlHttp.responseText); } } } function GetXmlHttpObject(){ var xmlHttp=null; try{ // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e){ // Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
Código HTML:
<html> <head> <script type="text/javascript" src="scripts/ajax.js"></script> </head> <body> <script>ajaxShow('', 'forms.asp', 'loadformdiv', '');</script> </body> </html>
Código HTML:
<script type="text/javascript" src="scripts/jquery.1.2.6.js"></script> <script type="text/javascript" src="scripts/jquery.date.js"></script> <script type="text/javascript" src="scripts/jquery.datepicker.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(function(){ $('.date-picker').datePicker().val(new Date().asString()).trigger('change'); }); }); </script> <input name="app_date" class="date-picker" value="" />
No sé si me expliqué, pero muchas gracias si tienen sugerencias (: