The short answer is that it depends, both on the needs of the team and the player involved. Each sport additionally has its own variables; Baseball has fully guaranteed and very large contracts, and a large prospect body (the minors). Football has non-guaranteed contracts with large signing bonuses (that don't follow the player, even in the salary cap hit) and no minor league, but players at some positions take years to develop while at other positions only have a few highly productive years. Basketball has a very small minor league, players who have instant impacts at relatively near their full potential, and guaranteed contracts with a salary cap. These aspects have a major impact on how trades work.
For baseball, some trades are basically dumps (minimal prospects or just 'cash', in exchange for salary relief - Adam Dunn for example), and some trades are for the prospects primarily (David Price, for example). Some trades are for a mixture of both, as the sending team agrees to pay some salary in exchange for a better prospect. The needs of the two teams and the prospects available drive that, plus the quality of the player traded. More value as a player means either more salary relief, or better or more prospect(s).
The long answer:
For baseball, you can generally think of a player as having two valuations: the cost of the player, and the actual production of the player valued in how much it would cost to replace that production on the free agent market. This, obviously, isn't an exact science, and each team likely has its own calculations on value. Additionally, you consider the productivity of the player he would replace in the lineup (when evaluating a player who will start or play for a winning team); filling a hole that has a negative-value player is obviously more interesting than one where a star already resides.
Teams making trades generally are considering both values together. A player who costs $10 million and produces at $15 million has $5 million in excess value; a player who costs $10 million and produces at $5 million has negative 5 million dollars in excess value. The former player would likely cost a significant prospect to acquire; the latter player might be traded for very little value (perhaps a minor prospect or two providing organizational depth, or simply for the salary dump).
In fact, you often see combinations: a team will trade a player and pay some of his salary, in exchange for a better prospect (or more prospects). Small market teams are less likely to be interested in this sort of trade (as the money has significant value); the Rays for example would prefer to trade more salary away, unless they like specific prospects a lot. The White Sox on the other hand have a relatively weak depth of minor league talent, and while not a top-tier team in terms of income can generally afford higher salaries, and thus are more interested in acquiring talent than solely dumping salary.
You can look at Fangraphs' Value section to get an idea of how much a player is valued. Typically, a WAR (win above replacement) is currently valued at around $5 million dollars (although this number varies by year, and generally increases over time). Let's take Adam Dunn as an example.
This year, he has been rated at 0.4 WAR, which equates to a value of around $2 million. He might earn another 0.1 the rest of the year, so say 0.5 million dollars from the date of the trade until the end of the year.
Oakland had a significant need at DH for a left handed bat (and for some power), and thus probably valued Dunn at higher than 0.1 WAR for the month; he is replacing essentially a below-replacement bat since Jaso was injured. They might value him at, say, 0.5 wins for the month, or even 1 win. Thus, they're willing to pay between 2.5M and 5M for him, in total value.
He had a total salary of about 2.3 million remaining for the month (of his $15 million), of which the White Sox paid $1.3 million and the Athletics paid $1 million. Thus, the Athletics are acquiring a bit of a bargain if they are indeed replacing negative WAR with his slightly positive WAR. The White Sox are losing very little value (they're out of the race, and didn't really need his bat anyway, as they have too many 1B bats already), so it didn't take much to convince them to give up Dunn: a former prospect turned reliever with shoulder issues, as Fangraphs describes it. Of course, the White Sox have a history of success rehabilitating prospects like this thanks to Don Cooper plus some luck, so this may also have been a plus from their side.
Either way, you can see that in this particular trade, you have one side trading away a relatively small trading chip for a relatively small gain- and the other side taking a small chip and some salary relief. This is pretty common in these sorts of trades.
Trades of players with high salaries AND high values, such as Cole Hamels, are harder to accomplish, because the Phillies would expect a good value prospect in return, but aren't really trading a lot of excess value: he is paid $20 million a year, and is worth about $20 million (around 4 WAR). You have to have a team who's in a very strong 'win now' mode, and has an extra prospect or two to cash in. This is more likely to happen with a team like the Cubs, for example, who might think they're basically there but have an extra top prospect without a need (they have 3 SS prospects, plus Starlin Castro, so they are worth more as trade chips than they are to the Cubs presently) and a desperate need for good starting pitching; someone like the Tigers or the Yankees probably don't have the depth to make a good trade, and have high salaries already.
Prospects have significant value in large part from their cost control due to the CBA. Players for their first 5 (usually) years are very underpaid (see the previous arbitration question for more details); the first two years they're typically paid under a million dollars each year, and even a top player will likely earn a total of $25 million for the 5 year span. That top player might earn 15 WAR over that span (or more!), thus producing a value of around $70 million for a cost of $25 million. Obviously, all but the top prospects are risky bets - even a graduated college senior like Carlos Rodon isn't a guaranteed sure thing; as such, that $55 million surplus is valued at something of a discount; but you might see something like $25 million in value from a top prospect, and even a near-replacement level player is worth at least $3-5 million in excess value - just 2 WAR over a six year span would be worth $10 million. This is how teams like Tampa Bay and Oakland manage to compete without high salaries; they have many 0.5-1 WAR players earning a million or less each, thus producing 10-15 WAR for the team as a whole without significant cost.