jquery日历在php中调用ajax后不显示

时间:2022-12-01 22:39:33

when page loads calender objects is displayed on the form. but when I call a ajax function from onchange event to select a city the calender is not displayed on page after the ajax call.The ajax code given as:

页面加载日历对象时显示在表单上。但是当我从onchange事件调用ajax函数来选择一个城市时,在ajax调用之后页面上没有显示日历.ajax代码给出为:

<script language="JavaScript">
function redirect()
{
    window.location='adm_regemployeelist.php';
}
function selectcity()
{

    var empid=document.getElementById("empid").value;   
    var empname=document.getElementById("empname").value;   
    var addr=document.getElementById("addr").value; 
    var addr1=document.getElementById("addr1").value;   
    var city=document.getElementById("city").value; 

    if(addr==''||empid==''||empname=='')
    {
        alert("Please Fill Out Empty Fields\n\n");
        return false;
    }

        if (window.XMLHttpRequest)
          {// code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
          }
        else
          {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
          }

        xmlhttp.onreadystatechange=function()
          {
          if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
                document.getElementById("container").innerHTML=xmlhttp.responseText;
            }
          }
        xmlhttp.open("GET","emp_registration.php?empid="+empid+"&empname="+empname+"&addr="+addr+"&addr1="+addr1+"&city="+city,true);
        xmlhttp.send();
}
</script>

please let me know if you need more information to help resolve the issue.

如果您需要更多信息来帮助解决问题,请告诉我们。

1 个解决方案

#1


0  

I think you are replacing the html element with the id 'birthdate' by ajax call wich is placed in container . So your calendar is no more associated with the 'birthdate' which is refreshed. Initiate it again after you get the ajax response and have replaced the 'container'

我认为你是用ajax调用替换html元素的id'birthdate'放在容器中。因此,您的日历不再与刷新的“生日”相关联。在获得ajax响应并替换'容器'后再次启动它

$( "#birthdate" ).datepicker({ changeMonth: true,
                      changeYear: true, 
                      dateFormat: 'dd/mm/yy', defaultDate: '-20y -1m -247d', minDate:'19/03/1960', maxDate:tdate, };

#1


0  

I think you are replacing the html element with the id 'birthdate' by ajax call wich is placed in container . So your calendar is no more associated with the 'birthdate' which is refreshed. Initiate it again after you get the ajax response and have replaced the 'container'

我认为你是用ajax调用替换html元素的id'birthdate'放在容器中。因此,您的日历不再与刷新的“生日”相关联。在获得ajax响应并替换'容器'后再次启动它

$( "#birthdate" ).datepicker({ changeMonth: true,
                      changeYear: true, 
                      dateFormat: 'dd/mm/yy', defaultDate: '-20y -1m -247d', minDate:'19/03/1960', maxDate:tdate, };