开发者

I expect to see in the browser "http://path/some_page.html" but instead it identifies with "http://localhost:8080/some_request"

I am developing with app engine SDK. I have a feeling this is much too basic a question so apologies ahead of time...

A simple submit button doesn't work instead of just showing an alert box as expected it continues on afterwards and redirects me to the latest http-request, and I think this is because I don't understand how to tell the browser to recognize the proper URLs.

Why does my browser say I am at the most recent http-request http://localhost:8080/putProjectInDB rather than the somepage.html that was actually served to the browser that I am currently looking at?

How can I get the browser to recognize and show in its url spot the normal expected http://somepage.html ?

Just in case, here are details of t开发者_运维知识库he specific problem which you might be able to ignore for answering the question:

This hasn't been mattered for me until I just wanted to put into my .html a simple button that changes some stuff of the page without needing the server. The below code after displaying the alert box redirects me to the last server request http://localhost:8080/putProjectInDB instead of just staying in the same html page.

in header:

function MyFormCommands() {
alert('Some Text');
}

in body:

<form onSubmit="MyFormCommands()" ><input type=submit ></form >


Why does the button need to live in a form? Why not just:

<input type="button" onclick="MyFormCommands();" value="Change it">

Totally without the form/submit problems. Also, you should avoid onsubmit/onclick in favor of addEventListener (or, better yet, a nice javascript library like jQuery).


Because, I'd say, http://somepage.html is no URL (you should read, by times, RFC 3986). You always need a server part (the 'stackoverflow.com' in your brwoser's address bar). If you test on a local machine, most web servers (and OSes) recognize the term 'localhost' as the server being the same machine as the client (== browser).

The ':8080' is the port. Mostly on the web, it would be port 80 for HTTP, and if this is the case, it is omitted from the URL. However, testing servers mostly use ports 8000 or 8080 to be sure not to get in conflict with possibly already existing live servers on the same machine.

If you want absolute URLs to reference to, but don't want the server part, leave away the 'http://' part as well and start with '/some/path/index.html'. Here, the web browser recognizes, that it is a path on the same server and will automagically insert that for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜