Im trying to do this :
When i add a student through my UI , using AJAX a row should get appended to the existing list(table) of students
So the feilds of my UI i sent to my controller, finished the db entry , from my controller i pass a Json object containing all the fields i want to show to my view (This is all working perfect).
In my view i did
success : function(result){
res = eval('('+result+')');
//Here the problem, begins , appending a row to the existing table:
$('#my_table tr:last').after('<tr>
<td>'+res.name+'</td>
<td>'+res.address+'</td>
<td><a href="javascript:void(0)">'+ res.flag== true ? "Male" : "Female" +'</a></td> // this is where im stuck !
</tr>')
}
The output is , it honestly checks for the flag value ie if flag== true it prints male , but its not displaying a link AND the gender is the ONLY thing that is displayed , not the name and address
If i remove the line
<td><a href="javascript:void(0)">'+ res.flag== true ? "Male" : "Female" +'</a></td>
It prints the name and address correctly, and if i add the line for checking the gender it prints ONLY The gender and it is NOT anchor Tagged , like its not a link
What am i doing wrong ?
try using this
just a difference of brackets but might do the thing