简体   繁体   English

我的Ajax在live()中不起作用

[英]My ajax doesn't work in live()

I have a link in my page and I wrote in it's onclick() event to show me a div that contain a date input text named "datepicker0" and also I have a div id ="bContent" below this input text. 我的页面中有一个链接,我在它的onclick()事件中写道,向我显示一个div,其中包含一个名为“ datepicker0”的日期输入文本,并且在此输入文本下方还有一个div id =“ bContent”。

Now I wrote below script and I want to apply date Filter on my data in "bContent", but it doesn't work! 现在,我写了下面的脚本,我想在“ bContent”中的数据上应用日期过滤器,但是它不起作用! Appreciate any help please... 感谢任何帮助...

$('#datepicker0').live('focus', function() {
    $(this).datepicker().datepicker('show');
    true;
 })
 $('#datepicker0').live('change', function() {
    ShowMathesByDateFilter($(this).val());
 })

and ShowMathesByDateFilter() Function is : 并且ShowMathesByDateFilter()函数是:

function ShowMathesByDateFilter(Fdate)
{

  if (Fdate=="")
  {
  $("#bContent").html('<div class="bContent" dir="rtl"> no result are fond! </div>');
      return;
  }
  else
  {
      $.ajax({
          url:'/includes/GetMtch.php',
          data:"Fdate="+Fdate,
          success: function(data){
              //alert(data);    // this is work 
              $("#bContent").html(data);   //but this line doesn't work.
          }
      })
  }
}

what version of jquery are you using? 您正在使用哪个版本的jquery? live is depreciated as of jquery 1.7: http://api.jquery.com/live/ 从jQuery 1.7开始,live贬值了: http : //api.jquery.com/live/

try using 'on' instead of live: http://api.jquery.com/on/ 尝试使用“ on”而不是live: http//api.jquery.com/on/

I agree with charlietfl's comment. 我同意charlietfl的评论。 There seems to be an issue with this line: 此行似乎存在问题:

$(this).datepicker().datepicker('show');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM