Reputation: 11446
I am trying to prepend some HTML to an AJAX created table. Here is the code:
success: function (msg) {
var ang = '';
var obj = $.parseJSON(msg);
$.each(obj, function() {
ang += '<table><tr><td width="165">' + this["Athlete_Name"] + '(' + this["Athlete_Number"] + ')</td><td width="55">'+ this["Scratch_Flag"] +'</td><td width="55">'+ this["Ready_Time"] +'</td><td width="55">'+ this["Flag_Time"] +'</td><td width="55">'+ this["End_Time"] +'</td><td width="55">'+ this["Score_Time"] +'</td></tr></table>';
});
$('<p>Roster</p>').prependTo('.html(ang)');
$('#' + ID ).hide().html(ang).fadeIn('fast');
}
The Line of code called:
$('<p>Roster</p>').prependTo('.html(ang)');
Is not appending to my array of HTML that is created called 'ang' could someone point me in the right direction? many thanks
Upvotes: 0
Views: 112
Reputation: 405
If you try add ang to $('
Roster
') element, than you must write some code like this:$(ang).prependTo('<p>Roster</p>');
But I really don't understand what that code means:
prependTo('.html(ang)')
Can you tell more info about .html command in target selector?
If you try to add <p>Roster</p>
element before your table, just put <p>Roster</p>
to ang declaration like:
var ang = '<p>Roster</p>';
Upvotes: 1