我正在开发一个简单的jquery应用程序,我想要做的是从表单中将username
和name
发布到Google App Engine。但是当我点击{{1}时没有任何反应以我的形式。
这是接受数据和提交按钮的表单
addEmpBtn
我的YAML文件看起来像这样
<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>
我正在使用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
编写jQuery-Mobile代码,我的项目目录结构如下所示
最后,这就是Webstorm
文件的样子
staff_game.js
由于没有显示任何错误消息,我无法分辨出什么是错误的。我甚至不确定我是否正确配置了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);
}
文件。
因为当我尝试像
YAML
没有任何反应。但我在某处读到这应该是用javascript(?)返回的东西。
我需要先申报清单吗?如果是这样的话?我做错了什么?