<div class="container">
<div class="row">
<div class="col-xs-8 col-md-8 col-lg-8 col-xs-offset-2 col-md-offset-2 col-lg-offset-2">
<form class="form-inline" id="form">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="nameasd" placeholder="Jane Doe" name="nameasd">
</div>
<button id="btn" type="button" class="btn btn-default" onclick="add_ajaxmessage()">提交</button>
</form>
</div>
</div>
</div>
<script type="text/javascript">
function add_ajaxmessage(){
var dataString =
'nameasd='+nameasd.value+ //这个值根据后台定义表单所设置的值
//'&yx='+yx.value+ //表单的name和id值必须一致,多个input请自行复制此行代码
'&action=post'+
'&diyid=1&do=2&dede_fields=nameasd,text&dede_fieldshash=bd9011ed660d9773441aa6c648a42f3f';
//这里的所有值都是根据自定义的值来修改
$.ajax({
type: "POST",
url: "/plus/diy.php",//提交到后台文件
data: dataString,//传值
success: function(data) {
//console.log(data)
$("#result").text(data);//以html的形式显示在指定id的元素里
$('#form')[0].reset();//提交后清除id="form"的值
}
});
return false;
}
</script>