2012-04-23 62 views
0

我想通过两个参数认为阿贾克斯。我从中拉出的变量在div中,并在飞行中完成。我可以轻松地通过date_time,但我需要也可以传递一个变量“id”。日期位于正在加载并更改的数组中。该页面的ID不会更改。通过AJAX传递多个参数。值来自DIV

这是javascript。下面将是我的分区。所有试图追加这个都失败了。有任何想法吗?

<div class='letter' width=600 date_time=\"$date_time\" id=\"$id\"> 
....doing stuff here..... 
</div> 

function OnScrollLetters() { var div = document.getElementById ("userLetter"); 
    var info = document.getElementById ("info"); 
    if(div.scrollTop == (div.scrollHeight - div.clientHeight)) 
    {  
     $('div#loadMoreComments').show(); 
     $.ajax({ 
     url: "get_letters_for_profile_scroll.php?lastComment="+ $(".letter:last").attr('date_time'), 
     success: function(html) { 
      if(html){  
       $("#userLetter").append(html); 
       $('div#loadMoreComments').hide(); 
      }else{ 
       $('div#loadMoreComments').replaceWith("<center><h1 style='color:red'>End of Letters</h1></center>"); 
      } 
     } 
     }); 
    } 
} 

这是我的div。

<div class='letter' width=600 date_time=\"$date_time\" id=\"$id\"> 
....doing stuff here..... 
</div> 
+1

其格?你能否检查你的问题并清除你的代码。 – Philipp 2012-04-23 23:53:15

+0

顶部的div。它不允许我发布。 div class ='letter'width = 600 date_time = \“$ date_time \”id = \“$ id \”> ....在这里做东西..... /div – 2012-04-24 00:34:56

+0

在我的div我是只需加载显示输出的数组即可。 ('。date_time')+“&id”+ $(“。letter:last”)。attr('id') url:“get_letters_for_profile_scroll.php?lastComment =”+ $(“。letter:last”)。 , 我会认为这会起作用,但它没有。 – 2012-04-24 01:32:07

回答

0

尝试放置一个 “=” 之间的参数名称和值

..."&id="+$(".letter:last").attr('id')