In case of doubt - alert()
or console.log()
is your best friend ;) Closely followed by specification of the QueryResult object (it's in different document than the AJAX toolkit developer guide...)
This should work:
function getProductTypes (oppId) {
var result = sforce.connection.query(...);
alert(result); // remove it once you're happy
return result == null ? 0 : result.size;
}