There are two different dichotomies at play here, ontology (realism/anti-realism), and methodology (foundationalism/anti-foundationalism). Kant was a foundationalist but (almost) an anti-realist, and Peirce, the founder of pragmatism, was a realist but an anti-foundationalist. The idea of foundation, from Plato to Kant, was that we need some basic/self-evident/unquestionable, etc., truths upon which the rest of knowledge is built and/or justified. The usual argument for it is that any knowledge needs justification, and justification can only derive from other knowledge, so unless there is self-justified knowledge (foundation) it will all be unjustified and arbitrary. This is the so-called foundation argument , and the beginnings of it can be found already in ancient skeptics, namely what was dubbed the Agrippa’s trilemma. Rationalists, like Kant and Plato, looked for this self-justified knowledge in the realm of reason, external or ours, empiricists, like Aristotle and Hume, took sense impressions/perceptions as its source.
Unfortunately, all (rationalist) candidates for foundational knowledge, including Kant’s synthetic a priori, were discredited by the middle of 19-th century, and science, seen as the most successful cognitive enterprise, seemed to rely not on justifying things up from unquestionable foundations, but rather by making hypotheses based on prior experience, testing them, and keeping/discarding them depending on the outcome. The entire process of self-correction served as justification, so there was no need for foundation to have justified knowledge, contra the classical foundation argument. Peirce’s pragmatism was a suggestion to import this mode of justification into philosophy, but without restricting it narrowly empirical testing, which is enriched by everyday experience, critical analysis and thought experimentation aimed at potential applications (including theoretical ones). In other words, a pragmatist takes what she assumes to be a fallible, at best temporary “foundation” to be tested, revised and improved upon based on its “practical bearings”. Here is from Some Consequences of Four Incapacities:
”We must begin with all the prejudices which we actually have when we enter upon the study of philosophy. These prejudices are not to be dispelled by a maxim, for they are things which it does not occur to us can be questioned… The result is that metaphysicians will all agree that metaphysics has reached a pitch of certainty far beyond that of the physical sciences; -- only they can agree upon nothing else. In sciences in which men come to agreement, when a theory has been broached it is considered to be on probation until this agreement is reached. After it is reached, the question of certainty becomes an idle one, because there is no one left who doubts it.
We individually cannot reasonably hope to attain the ultimate philosophy which we pursue; we can only seek it, therefore, for the community of philosophers…
Philosophy ought to imitate the successful sciences in its methods, so far as to proceed only from tangible premisses which can be subjected to careful scrutiny, and to trust rather to the multitude and variety of its arguments than to the conclusiveness of any one. Its reasoning should not form a chain which is no stronger than its weakest link, but a cable whose fibers may be ever so slender, provided they are sufficiently numerous and intimately connected.”
Through Lewis, Peirce’s conception of epistemology influenced Quine’s, although he reduced justification to narrowly scientific only, and even suggested to subsume epistemology under psychology, see Is Peirce's pragmatic maxim self-evident? Wittgenstein was influenced through James's writings and Ramsey, his late refrains, "meaning is use" and "grasping a rule that is not an interpretation", rephrase Peirce's pragmatic maxim and habit change analysis, respectively, see Hookway's
Truth, Rationality, and Pragmatism, Ch.5.
The problem of “criterion of correctness” at the end of the OP is legitimate. But it actually supports pragmatism more than foundationalism. It is true that in order to improve we need to sense that something is amiss. It does not follow that we must have some sense of how things should be. We may be able to tell that something does not work properly without having any idea how it works or how to fix it, animals react to dangers in their environment instinctively, presumably without understanding why at all, so at times do we. But even if we did always have such a sense it certainly does not follow that we must have unshakably secure basic knowledge to justify the rest of knowledge afterwards. What we need for justification is neither preliminary intuition (although it helps at the discovery stage), nor foundation, but a way to tell success from failure as it concerns our knowledge when applied to our ends. That is genuine doubt, is exactly what Peirce says sets off any inquiry, see How far can/should one press philosophical doubt?
As for mind-independent reality, pragmatists do not understand it in the metaphysical/posit/model sense of traditional realism, with one or another "myth of the Given" serving as the foundation. Reality is rather understood as non-conceptual constraint on our conceptual productions. In this sense pragmatists are not traditional rationalists, but rather "rational pragmatists", as Brandom put it. Peirce argued that concepts ultimately reduce to habits of conduct, or rather conditional forks in them, and it is in the conduct that the "will" confronts reality. Short's
Peirce's Theory of Signs describes Peirce's realism in detail.
So was pragmatism successful in moving away from "necessity" (which I take to mean something like a priori principles for grounding knowledge)? It would certainly be an exaggeration to say that pragmatism "refuted" or replaced foundationalism. What it did do is offer an alternative paradigm of justifying knowledge that proved viable so far. In that it removed one of the major appeals of foundationalism: that the alternative is having no knowledge worth the name at all. And that is perhaps as much of a success as one can hope for in philosophy.