Ajax request: 500 (Internal Server Error)
At a glance, there's some issues with the code, however, the main error may be:

$product = entity_load_single('product', $pid);


where you don't have a $pid value, you're setting $fid instead.

$fid = $_POST['pid'];