I remember way back, before the surge was agreed by most (except for politically minded Dems) to be a turning point in the war in Iraq. Back then, Democrats, including and especially Barack Obama, were riding high on morals, claiming that we couldn't win in Iraq, and that even if we wanted to, we wouldn't be able to define what winning meant. Their answer: Cut our losses, get out now. Then, John McCain suggested the very unpopular idea of the surge - double down, send even more troops into this quagmire.
This ballsy idea worked; and now Democrats, led by Obama's inspirational foreign policy platform, can play a different tune - claiming to be hawks by wanting a similar surge (they won't call it that) for the fight in Afghanistan; meanwhile demanding an exit from Iraq, given that we aren't seemingly needed there anyway. Obviously, the benefits of John McCain's surge enabled Obama to take this position, even if he and other Dems don't want to admit to this under any circumstances. Moreover, Obama's solution for Afghanistan, sending more troops to kill and capture Al Qaeda and other insurgents, is essentially the same as McCain's idea for a surge in Iraq to accomplish the same thing.
Citing Obama's lack of foreign policy creds, his very popular (with the left) policy for "ending the war in Iraq," and the fact that Obama hadn't even been to Iraq in quite some time, John McCain suggested that Obama go to Iraq and see first hand the progress made as a result of the surge. Once there, Obama would have to see the light, and possibly revisit his "out in 16 months" policy, McCain thought. After much massaging of the idea, peeing on it to make it his own and such, Obama decided he was going on a fact-finding tour in Iraq, and Afghanistan, as well as Israel, the Palestinian territories, Europe and elsewhere.