Presidential candidates Barack Obama and John McCain have traded jokes not jabs at a high-profile political dinner in New York.