Appending a TR to Table Not Formatting Correctly
Posted
by
TimNguyenBSM
on Stack Overflow
See other posts from Stack Overflow
or by TimNguyenBSM
Published on 2013-11-12T21:51:41Z
Indexed on
2013/11/12
21:52 UTC
Read the original article
Hit count: 182
My PHP script is sending back an array:
$currentStatus = ( isset( $status ) ) ? "1" : "0";
$html = "<tr><td>" . $email . "</td><td>" . ( ( $status->type == 0 ) ? "View Only" : ( ( $status->type == 1 ) ? "View & Mark" : "View, Mark & Edit" ) ) . "</td><td>Invited</td></tr>";
echo json_encode( array( $html, $currentStatus ) );
Then my jquery is appending this to the table:
...
success: function( result ) {
var resultArray = eval( result );
$( "#myTable tr:last").append( resultArray[0] );
...
}
Problem is, when it prints, it prints the following extra marks:
[email protected]<\/td> View Only<\/td> Invited<\/td><\/tr>","1"]
If I only echo the HTML it appends to table just fine, but I cant do that because I need the $currentStatus back too to do something with it.
Thanks!
© Stack Overflow or respective owner