I am working on a simple jquery app and want i want to do is post a username
and name
to Google App Engine from a form.But nothing happens when i click the addEmpBtn
in my form.
This is the form for accepting the data and the submit button
<form id="post" action="http://localhost:8070/addNewEmployee" method="post">
<input id="username" name="user" placeholder="Username" type="text" size="30"/>
<input id="name" name="name" placeholder="Name" type="text" size="30"/>
<a href="#" id="addEmpBtn" data-theme="b" data-role="button" data-inline="true">Register</a>
</form>
My YAML file looks like this
application: get-post-test
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /html
static_dir: html
- url: /js
static_dir: js
- url: /png
static_dir: imgs
- url: /.*
script: main.app
I am writing the jQuery-Mobile code using Webstorm
and my project directory structure looks like this
Finally, this is what the staff_game.js
file looks like
URL = "http://localhost:8070/addNewEmployee";
$(document).ready( function() {
$("#addEmpBtn").bind('click', function(event){
addNewEmployee();
event.preventDefault();
});
});
function doPostRequest(postData) {
$.ajax({
type: "POST",
url: URL,
data: postData,
dataType: "json"
}).done(function(data, textStatus, jqXHR){
// This clears out the message sent.
$("#username").val('');
$("#name").val('');
setTimeout(doGetRequest, 1000);
}).always(function(data, textStatus){
});
}
function addNewEmployee() {
//Encode the user-id and message as a single JSON
// object, in name:value pairs...
var struser=$("#username").val(),
strmessage=$("#name").val(),
postData = {username: struser, name: strmessage};
// Now use this data in a POST operation...
doPostRequest(postData);
}
Since there aren't any error messages to show, i can't tell what's wrong.I am not even sure i have configured the YAML
file correctly.
Because when i try something like
localhost:8070/js/staff_game.js
nothing happens.But i read somewhere that this is supposed to return something in javascript(?).
Do i need to declare a manifest first? if so how? What am i doing wrong?