Javascript 过帐表单数据Jquery
我正在尝试构建一个移动应用程序,但在获取Jquery/Javascript的基础知识时遇到了一些困难。 我正在尝试这样做,以便我可以在输入字段中键入任何我想要的值,然后发布它,它将在上面发布,并允许我在输入字段中键入更多内容,它将在最后一篇文章上方发布 这是到目前为止我的代码。不知下一步该去哪里,或者我是否走对了方向Javascript 过帐表单数据Jquery,javascript,jquery,post,Javascript,Jquery,Post,我正在尝试构建一个移动应用程序,但在获取Jquery/Javascript的基础知识时遇到了一些困难。 我正在尝试这样做,以便我可以在输入字段中键入任何我想要的值,然后发布它,它将在上面发布,并允许我在输入字段中键入更多内容,它将在最后一篇文章上方发布 这是到目前为止我的代码。不知下一步该去哪里,或者我是否走对了方向 <!DOCTYPE HTML> <HTML> <script src="http://code.jquery.com/jquery
<!DOCTYPE HTML>
<HTML>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$('#commentForm').submit(function(){ //listen for submit event
$.each(params, function(i,param){
$('<input />').attr('type', 'show')
.attr('value', param.value)
.appendTo('#commentForm');
});
return true;
});
</script>
<BODY>
<form id="commentForm" method="POST">
<textarea cols="30" rows="6" name="comment" title="Enter a comment">
</textarea>
<input type="submit" value="Post"/>
<input type="reset" value="Reset"/>
</form>
<div id="box">
</div>
</BODY>
</HTML>
$('#commentForm').submit(函数(){//侦听提交事件
$.each(参数,函数(i,参数){
$('').attr('type','show')
.attr('value',参数值)
.appendTo(“#commentForm”);
});
返回true;
});
给提交按钮一个名为“提交”的id
我正在使用此脚本登录用户。
PS:您将从php解释器“回显”的所有内容都将显示在div上,id为“notification”,您将(可能)创建它
function onSuccess(data, status) {
data = $.trim(data);
//make a div with id "notification" before running this code
$("#notification").html(data);
$.mobile.hidePageLoadingMsg(); //used on jquery mobile to hide a loader
}
function onError(data, status) {
data = $.trim(data);
$("#notification").html(data);
$.mobile.hidePageLoadingMsg(); //used on jquery mobile to hide a loader
}
$("#submit").click(function() {
$.mobile.showPageLoadingMsg(); //used on jquery mobile to show a loader
var formData = $("#commentForm").serialize(); //get all data from form
//do the POST thingies
$.ajax({
type: "POST",
url: "url_to_your_php_interpreter",
cache: false,
data: formData,
success: onSuccess,
error: onError
});
return false;
});