Solved. I dont' know exactly what was wrong, although it was most probably in the callback function. Maybe the carriage returns.
But this works fine: $.ajax({ async: false, url: cart_doc, type: 'POST', data: {action: 'retrieve_opt', name: fieldName}, dataType: 'text', timeout: 1000, error: function(){ alert('Error retrieving product option value'); }, success: function(chosenOption) { field.value=chosenOption; alert(field.value); } }); Bye.