There are several possible issues. Suggestions: 1) restart the router 2) change the security to WPA/WPA2 TKIP 3) change the channel 4) enter fixed IP and DNS info in your S4. 5) tap the connection - forget - restart the S4 and reconnect,
Try another wifi network and see if it has any issues. If it does, reboot your phone before taking any more drastic issues. Also, if it seems to be the phone, if you installed any power management software such as Juice Defender, then try disabling it.