Luke 11.9-10: 9 So I say to you, ask, and it will be given to you; seek, and you will find; knock, and it will be opened to you. 10 For everyone who asks, receives; and he who seeks, finds; and to him who knocks, it will be opened.
James 4.3: 3 You ask and do not receive, because you ask with wrong motives, so that you may spend it on your pleasures.
Refer also to Matthew 21.22 = Mark 11.24.
James 4.3 certainly looks like a reaction to Matthew 7.7-8 = Luke 11.9-10, and not the other way around. It sounds like Matthew 7.7-8 = Luke 11.9-10 was written or spoken first; then people tried to follow its simple principle, and that principle failed (because that is not how life works); and then, finally, James 4.3 was written as an explanation for why the principle failed. Does it not? This observation, if sound, would rule out any such simplistic scenario as James -> Matthew (though of course it does not rule out Matthew -> James).