Please perform the following actions and after each one test to see if the problem is resolved - if so then you can omit the following steps - I have tried to list them in order of increasing effort at least on a Mac and / or an iDevice
Check to see if the problem is isolated to one device and if other devices connect normally -
If the answer to 1 is "yes" - try to connect the affected device in another location if possible - café or university
Please see Apple's recommended settings for Wi-Fi routers and access points
Perform a forced restart - this does not delete or purge any data and troubleshoots many issues - here is how - Hold down the Off/On and Home buttons at the same time for about 15-20 seconds until the Apple logo appears. Allow normal boot up.
Settings - WiFi - <network name> - Click on forget the network - do a forced restart as per 4 and then add the network again
If at home - reboot the router by unplugging for 60 seconds from the AC (mains) and then plug it back in - obviously this step cannot be done in a public place as a café/airport or university. While you are at it - make sure your router is operating on the latest firmware (check manufacturer site)
Settings - General - Reset - Reset Network Settings - remember to have WiFi passwords handy since this erases stored WiFi passwords
If this is a net new device especially in your home - make sure the router is giving enough DNS numbers to accommodate everything that needs / wants a connection - stuff like the printer, Chromecast get overlooked - ask for details about this if not sure
Backup the device to iTunes - Restore as NEW (not from backup) using iTunes - see if problem resolves - if yes - restore backup
Make a "Genius" appointment at an Apple Store, or go to another authorized service provider.