You must have specified LOCALHOST by using any of local web server.. if you are accessing external files for data. i.e. Wamp, or Xamp.. there are few more too. ... as you said.. it works when you uploaded on website.. its mean you are using external contents being called (ajax).. isn't it.. ?
If so please download and install wampserver. Its free and easy to install.