I have var row=valval2 and I tried this:
var row=valval2
$(\"#mainTable tbody\").append(row);
You can use prepend JQuery method that inserts as the first child:
$("#mainTable tbody").prepend(row);
Prepend documentation