Either your router isn't allowing the connection to go to the internet (a local connection - that's something to do with your router, not your phone) or the server you're trying to get to isn't there (use a browser in your phone and try to come here - or to save typing, go to aol.com - if that works it's a problem with the server you're trying to go to and there's nothing you can do about it).
For the first problem, your internet service provider's tech support MIGHT be able to help - it depends on whether they have actual tech support people or clerks who read answers from their computer screens.
If things work on data but the same things don't work on wifi, it's probably the first problem - something with your router setup.