views:

37

answers:

2

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 doesnt 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 dont 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 the specific problem which you might be able to ignore for answering the question:

This hasnt 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 >
+1  A: 

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).

Jason Prado
+1. Or, just make MyFormCommands() `return false;` after the alert message.
npdoty
Interesting. Why should `onclick` be avoided Jason? Any exploits?
Jorge
onclick makes it easy to shoot yourself in the foot. An element can only have one onclick and if you overwrite it the old one is just lost. Event listeners, on the other hand, can be stacked.
Jason Prado
A: 

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.

Boldewyn
I think my question was poorly asked....my app serves likes this:class PutProjectInDBthenDesignPage(webapp.RequestHandler):path=os.path.join(os.path.dirname(__file__),'type_on_map.html')self.response.out.write(template.render(path, template_values))so the browser's adddress bar then says:http://localhost:8080/putProjectInDBbut is it possible to get it to say instead "/path/type_on_map.html"
indiehacker