Why does my program go into an infinite loop when someone enters an invalid input character?

Why does my program go into an infinite loop when someone enters an invalid input character?

#include<iostream>
using namespace std;
void mainMenu()
{
	int ch;
	cout<<"Main Menu"<<endl;
	cout<<"1. Customer"<<endl;
	cout<<"2. Item"<<endl;
	cout<<"3. Shopping"<<endl;
	cout<<"4. Quit"<<endl;
	cout<<"Choose one: "<<endl;
	cin>>ch;
	while( cin.fail() ) 
	{
cout << "Bad input, try again." << std::endl;
// Reset the stream.
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(),''\n'');
cin>>ch;
	}
// until you enter integer value you will
//try to input new value

}