Watch the SECTION 1: The Reactive Approach online guitar lesson by Jon Herington from Ear IQ: Reactive Improvisation
I get a lot of students who come to me because they're frustrated with their soloing on songs with chord changes that temporarily go out of the key. I’m going to show you a method of finding the notes that "work" best on any given chord in the context of a song, then work to apply that understanding to playing on changes. (The high art of playing on chord changes is the hallmark of the jazz tradition, of course, but the current pop/rock/R&B formats frequently have songs with the occasional chord that goes out of the key, and I've found a foolproof way to get students to develop strategies for negotiating those changes without requiring the serious extended study most aspiring jazz players undertake.) To do this, you're going to have to listen well and trust your ear.