dsbowmvth16379079 2012-09-18 09:40
浏览 26
已采纳

Javascript日期选择器无法在ajax中运行

I am using this code

window.onload = function(){
        new JsDatePick({
            useMode:2,
            target:"report_date_start",
            dateFormat:"%d-%M-%Y"
        });
        new JsDatePick({ 
        useMode:2, 
        target:"report_date_end", 
        dateFormat:"%Y-%m-%d"
        });
      };
function dwnyear_click(id)
{
    var urls=siteurl+"?action=Date_range&id="+id;
    $.ajax({  
        type: "POST",  
        url: urls,  
        success: function(msg)
        {
            $("#dwn_year").html(msg);
            $("#dwnyear_dropdown").css("display","none");}
    });             
}

<input name="report_date_start" type="text" id="report_date_start"  />
<input name="report_date_end" type="text" id="report_date_end"  />

I need to load the textboxes to form via ajax, the datepicker is not working. I have used the same datepicker in my site without any problems. How to tackle this problem? I have added ajax code. Onsuccess returns the textfields

  • 写回答

1条回答 默认 最新

  • doujiu9307 2012-09-18 09:45
    关注

    I don't think the window.onload event will trigger when you are loading that code in via an AJAX request as the page has already loaded.

    You should try having your Javascript on the original page, or maybe rather than using that event put the code into an AJAX success event instead which will trigger when the AJAX request has completed successfully.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA