Welcome to WebmasterWorld Guest from 54.196.232.162

Forum Moderators: open

Message Too Old, No Replies

jquery ajax load issue

     
9:28 pm on Apr 9, 2010 (gmt 0)

Preferred Member

5+ Year Member

joined:June 19, 2006
posts: 476
votes: 0


<script language="javascript">
$(document).ready(function() {
$(".hidden_info").hide();
$(".clicker").click(function () {
$(this).parent().next(".hidden_info").toggle();
$(".result").empty().html('<img src="/img/load.gif" />');
$.ajax({
url: 'get_person_info.php',
global: false,
type: "GET",
data: ({id : this.getAttribute('id')}),
success: function(data) {
$(".result").html(data);
}
});

});
});
</script>

I am trying to replace the line
$(".result").html(data);

with something like
next$(".result).html(data)

Because Im populating my list dynamically I only want it to load ajax content into the next class named result. Ive been trying to get this now for 5 hours and have tried everything. Any help would be much appreciated.

Here is my html & php code

<tr class="row<?=($var++%2)?>">
<td class="clicker" id="<?=$temp_id?>">
<a href="#"><?=$last_name_results?>, <?=$first_name_results?></a>
</td>
<td><?=$total_difference?></td>
<td><?=$rank_difference?></td>
<td><?=$radio_difference?></td>
<td><?=get_type($type)?></td>
</tr>
<tr class="hidden_info">
<td colspan="5" class="result"></td>
</tr>
10:00 pm on Apr 9, 2010 (gmt 0)

Full Member

10+ Year Member

joined:Nov 3, 2003
posts:324
votes: 0


Do you mean you will have multiple td with the class "result" but you only want your output to load into one of them? If so, you can't do what you want.

I would name each td different names (result1, result2, etc) and submit that name as a variable on "clicker" then output that variable to your .html statement.
11:21 pm on Apr 9, 2010 (gmt 0)

Preferred Member

5+ Year Member

joined:June 19, 2006
posts: 476
votes: 0


@stajer how would I "submit that name as a variable on "clicker" then output that variable to your .html statement. "
2:13 am on Apr 11, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
posts:1585
votes: 0


Try this, warning I am still learning jQuery

<script language="javascript">
$(document).ready(function() {
$(".hidden_info").hide();
$(".clicker").click(function () {
$(this).parent().next(".hidden_info").toggle();
var result = $(this).parent().next(".hidden_info").next(".result");
result.empty().html('<img src="/img/load.gif" />');

$.ajax({
url: 'get_person_info.php',
global: false,
type: "GET",
to: result,
data: ({id : this.getAttribute('id')}),
success: function(data2) {
to.html(data2);
}
});

});
});
</script>