post方式提交数据
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>
我的第一个ajax
</title>
<link href="css/style.css" rel="stylesheet"/>
<link href="css/bootstrap.min.css" rel="stylesheet"/>
<script src="js/jquery-1.9.1.min.js"></script>
</head>
<body>
<div id="box" style="border:1px solid red;display: block;clear: both; width: 500px; height: 40px; margin:20px auto;">
</div>
<form id="form">
<div class="form-group">
<label>姓名:</label>
<input type="text" class="form-control " placeholder="姓名" name="user" >
</div>
<div class="form-group">
<label>价格:</label>
<input type="text" class="form-control" placeholder="价格" name="price" >
</div>
<div class="form-group">
<label>描述:</label>
<textarea class="form-control" rows="3" name="description"></textarea>
</div>
<div class="form-group">
<label>上传图片:</label>
<input type="file" name="img">
</div>
<center>
<button type="button" class="btn btn-default" name="submit">
提交
</button>
</center>
<div class="submit">
<span class="loading">正在提交...</span>
</div>
</form>
<script>
$(function() {
$('form button[type=button]').click(function() {
$.ajax({
type: "POST",
url: "formtest.php",
// 表单序列化
data: $('form').serialize(),
success: function(response, status, xhr) {
$('#box').html(response);
},
error: function(xhr, errorText, erroType) {
//alert('错误');
//alert(errorText+":"+erroType);
alert(xhr.status + ":" + xhr.statusText);
}
});
}); // $('form button[type=button]').click(function() {
// $.ajax({
// type: "POST",
// url: "formtest.php",
// //param() 方法用于在内部将元素值转换为序列化的字符串表示
// data:$.param({
// user:$('form input[name=user]').val(),
// price:$('form input[name=price]').val(),
// description:$('form textarea[name=description]').val()
// }),
// success: function(response, status, xhr) {
// $('#box').html(response);
// },
// error: function(xhr,errorText,erroType) {
// //alert('错误');
// //alert(errorText+":"+erroType);
// alert(xhr.status+":"+xhr.statusText);
// }
// });
// });
$(document).ajaxStart(function() {
$('.loading').show();
}).ajaxStop(function() {
$('.loading').hide();
});
})
</script>
</body>
</html>
formtest.php
<?php
echo $_POST['user']."-".$_POST['price']."-".$_POST['description'];
?>
post方式提交数据的更多相关文章
- Android 采用post方式提交数据到服务器
接着上篇<Android 采用get方式提交数据到服务器>,本文来实现采用post方式提交数据到服务器 首先对比一下get方式和post方式: 修改布局: <LinearLayout ...
- Android(java)学习笔记213:开源框架post和get方式提交数据(qq登录案例)
1.前面提到Http的get/post方式 . HttpClient方式,实际工作的时候不常用到,因为这些方式编写代码是很麻烦的 2.Android应用会经常使用http协议进行传输,网上会有很完善 ...
- Android 使用Post方式提交数据(登录)
在Android中,提供了标准Java接口HttpURLConnection和Apache接口HttpClient,为客户端HTTP编程提供了丰富的支持. 在HTTP通信中使用最多的就是GET和POS ...
- Android 使用Post方式提交数据
在Android中,提供了标准Java接口HttpURLConnection和Apache接口HttpClient,为客户端HTTP编程提供了丰富的支持. 在HTTP通信中使用最多的就是GET和POS ...
- 苹果微信浏览器不能post方式提交数据问题
form表单中采用post方式提交数据时,在苹果的微信浏览器中无法传递,安卓的可以 如图: 在controller中获取该数据为 null 将表单的提交方式修改为get就能够获取到 现在采用Ajax方 ...
- Android(java)学习笔记156:开源框架post和get方式提交数据(qq登录案例)
1. 前面提到Http的get/post方式 . HttpClient方式,实际工作的时候不常用到,因为这些方式编写代码是很麻烦的 2. Android应用会经常使用http协议进行传输,网上会有很 ...
- postman 中post方式提交数据
post方式提交数据时,把参数填写在body中而不是pOST下面的哪一行
- Android 采用get方式提交数据到服务器
首先搭建模拟web 服务器,新建动态web项目,servlet代码如下: package com.wuyudong.web; import java.io.IOException; import ja ...
- JQuery以JSON方式提交数据到服务端
JQuery将Ajax数据请求进行了封装,从而使得该操作实现起来容易许多.以往我们要写很多的代码来实现该功能,现在只需要调用$.ajax()方法,并指明请求的方式.地址.数据类型,以及回调方法等.下面 ...
- easyui form 方式提交数据
http://ldzyz007.iteye.com/blog/2067540 <form id="ff" method="post"> . ...
随机推荐
- Java调用MQ队列
IBM MQ 6.0中设置两个队列,(远程队列.通道之类都不设置). 队列管理器是XIR_QM_1502 队列名称是ESBREQ IP地址是10.23.117.134(远程的一台电脑,跟我的电脑不在一 ...
- Python标准异常和异常处理详解
python提供了两个非常重要的功能来处理python程序在运行中出现的异常和错误.你可以使用该功能来调试python程序. 1.异常处理: 本站Python教程会具体介绍. 2.断言(Asserti ...
- gitlab 使用现有 nginx 服务器
gitlab 安装自带 nginx,如果想利用原有 nginx,可按如下操作: 8.0 版本 socket 文件位置有变动,感谢评论区的同学. nginx 增加虚拟主机配置 # gitlab sock ...
- sqlserver连接问题收集
问题1. 使用navicat连接本地sqlserver,报错“命名管道提供程序无法打开与 sql server 的连接 [2]” 解决: 参考本篇文章 <持续收集中>
- 【NET多线程】C#多线程异步请求多个url地址
异步测试代码 System.Diagnostics.Debug.Print("start"); new Thread(new ThreadStart(new Action(() = ...
- docker 快速搭建Nexus3
1.拉取镜像 docker pull sonatype/nexus3 2.启动容器 : -p : -p : -v /mnt/gv0/nexus-data:/nexus-data sonatype/ne ...
- 自己实现atoi
bool myatoi(const char *s,int &num) { cout<<(&s)<<endl; num=; while (*s) { ') { ...
- 原生js--userData
userData是IE5及其以上浏览器支持的一种客户端存储方式,它通过在document元素后面附加一个专属的元素来实现. 对userData的封装: /** * IE userdata封装 */fu ...
- laravel连sql server报invalid handle returned问题解决方案
https://github.com/Microsoft/msphpsql/issues/116 4.1.1驱动下载地址 https://github.com/Microsoft/msphpsql/r ...
- 改变vux样式
场景:修改 x-header 颜色 解决: 在创建文件路径如下 src/assets/less/theme.less ; 在build/webpack.base.conf.js下添加 这两行即可