2012-09-12 37 views

回答

1

您正在使用两个具有相同ID的标签。您不能在HTML中拥有该标签,因此只有第一个呈现的标签才会使用该标识。带班尝试它,而不是:

var hoverHTMLDemoAjax = '<p><label class="username"></label></p>'; 
    $(".demo-ajax").hovercard({   
    detailsHTML: hoverHTMLDemoAjax, 
    width: 100, 
    delay: 500, 
    onHoverIn: function() { 
     $.ajax({ 
      url: '/echo/json/', 
      type: 'GET', 
      dataType: 'json', 
      beforeSend: function() {     
       $(".username").prepend("<p class='loading-text'>Loading ...</p>"); 
      }, 
      success: function (data) { 

       var justatext="testing text goes here";     
       $(".username").html(justatext);     
      }, 
      complete: function() { 
       $('.loading-text').remove(); 
      } 
     }); 
    } 
});​ 

http://jsfiddle.net/brightpixel/rDGe5/

+0

嗨,约翰,需要一个更多的帮助。我想通过在Ajax调用悬停标签的HTML屁股说法。所以请帮助如何确定哪个标签悬停在onHoverIn:function()中。谢谢 –

+0

如果你看看这个页面,你可以看到hovercard的选项:http://designwithpc.com/Plugins/Hovercard,然后你可以通过jQuery访问这些部分 – John

+0

谢谢约翰,但我不能在那里发现我是什么需要。你可以帮助代码 –

2

结帐的JSFiddle

var hoverHTMLDemoAjax = '<p><label id="username"></label></p>'; 
$(".demo-ajax").each(function(){ 
    var _this = $(this); 
    _this.hovercard({   
     detailsHTML: hoverHTMLDemoAjax, 
     width: 100, 
     delay: 500, 
     onHoverIn: function() { 
      $.ajax({ 
       url: '/echo/json/', 
       type: 'GET', 
       dataType: 'json', 
       beforeSend: function() {     
        _this.parent().find("#username").prepend("<p class='loading-text'>Loading ...</p>"); 
       }, 
       success: function (data) { 
        console.log(_this); 
        var justatext="testing text goes here";     
        _this.parent().find("#username").html(justatext);     
       }, 
       complete: function() { 
        $('.loading-text').remove(); 
       } 
      }); 
     } 
    }); 

}); 
+0

谢谢abhidev ..你的解决方案是帮助我克服我的第二个问题在指定的意见。 –

+1

很高兴它解决了你的问题 – Abhidev