/    Sign up×
Community /Pin to ProfileBookmark

access local html page through "file:///"

I installed LAMP
and I want to use ajax to write some client information into mysql server on the server side.
I want to test a anonymous browser.
however, with this browser, pages like “http://localhost/test.html” can’t be accessed because the browser can’t establish a connection to the server at localhost.
but it can access the page through: file:///var/www/html/test.html

however, my intention is to use ajax to write some client information into mysql server on the server side, so through file:/// can’t achieve this goal,
are there any potential solutions for this?
thanks!

to post a comment
Full-stack Developer

5 Comments(s)

Copy linkTweet thisAlerts:
@daihuwsOct 23.2012 — If you can't connect to your page by using localhost it sounds very much like your web server isn't running.

What happens when you try and (re)start Apache from the command line? Does it spit out any error messages?
Copy linkTweet thisAlerts:
@esolveauthorOct 24.2012 — it is running, but the browser has some settings that disallow it to access localhost

I'm just wondering whether it is possible to log client information to the server sql database if I use "file:///"
Copy linkTweet thisAlerts:
@daihuwsOct 24.2012 — > it is running, but the browser has some settings that disallow it to access localhost

Really? How does that happen? Are you using a computer that has certain settings restricted beyond your control? Every browser that I've ever used can connect to localhost / 127.0.0.1 - with the possible exceptions of Internet Explorer and Safari, but given that they don't run on Linux I haven't used them for aeons.

> I'm just wondering whether it is possible to log client information to the server sql database if I use "file:///"

It depends which languages you're using. PHP will only run via an intermediary web server. JavaScript will work.

Even if you don't need PHP and can get by just with JavaScript, I'd caution against it. Your development environment should mirror as closely as possible the environment in which you eventually deploy your work, e.g. if the server where you anticipate deploying your work is running Debian 6, then do your web development on an instance of Debian 6. (this is where virtual machines come in hand.)

Otherwise, you'll be prone to finding that certain things don't work exactly as you expected when your work is set to go live.
Copy linkTweet thisAlerts:
@esolveauthorOct 24.2012 — I just want to use youtube API to get some statistics information and log these information

but I can't use javascript to create files for logging these information on client side, so someone suggests me to set up a webserver and use ajax

however, I'm investigating Tor browser bundle and this browser can't access localhost

I don't want that the webserver locates in another machine, because I don't want the delay between the client and the server (it can be several seconds due to Tor browser routing)
Copy linkTweet thisAlerts:
@daihuwsOct 24.2012 — Oh, I see.

In that case, the best idea I can think of would be to write a program in JavaScript that periodically appends the relevant information to your browser window, preferably in a convenient data interchange format such as JSON. Then, when you've got the information you need, you could save the data from your browser window as a text file, process it with a scripting language of your choice (virtually every language under the sun supports JSON) and then input it to your MySQL database. Well, that's probably how I'd attempt to do it. Can't really offer any more specific advice - unfortunately know nothing at all about the YouTube API.
×

Success!

Help @esolve spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...