homepage Welcome to WebmasterWorld Guest from 54.163.72.86
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
jquery ajax load issue
drooh




msg:4113223
 9:28 pm on Apr 9, 2010 (gmt 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>

 

stajer




msg:4113261
 10:00 pm on Apr 9, 2010 (gmt 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.

drooh




msg:4113313
 11:21 pm on Apr 9, 2010 (gmt 0)

@stajer how would I "submit that name as a variable on "clicker" then output that variable to your .html statement. "

daveVk




msg:4113732
 2:13 am on Apr 11, 2010 (gmt 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>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved