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"> . ...
随机推荐
- python --->字典 集合 学习笔记
1.字典--->创建空字典:dict={} broa=["李宁",”耐克“,“阿迪达斯”,“鱼c工作室”] sloga=[“A”,“B”,“C”,“D”] dict={&qu ...
- React Native(六)——PureComponent VS Component
先看两段代码: export class ywg extends PureComponent { …… render() { return ( …… ); } } export class ywg e ...
- django rest framwork教程之 viewsets和routers
ViewSets 和Routers REST框架包括一个用于抽象处理的ViewSets,允许开发人员集中精力对API的状态和交互进行建模,并根据常见约定自动处理URL构造. Viewset 类和 Vi ...
- 【cs229-Lecture11】贝叶斯统计正则化
本节知识点: 贝叶斯统计及规范化 在线学习 如何使用机器学习算法解决具体问题:设定诊断方法,迅速发现问题 贝叶斯统计及规范化(防止过拟合的方法) 就是要找更好的估计方法来减少过度拟合情况的发生. 回顾 ...
- 题目1441:人见人爱 A ^ B(二分求幂)
题目链接:http://ac.jobdu.com/problem.php?pid=1441 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...
- [转]RedHat Enterprise Linux 7关闭防火墙方法
在之前的版本中关闭防火墙等服务的命令是 service iptables stop /etc/init.d/iptables stop 在RHEL7中,其实没有这个服务 [root@rhel7 ~]# ...
- OpenStack cloud 第一天
这是刚接触openstack时候,看到的第一篇文章,感触很深,自己很喜欢的一个词Horizon就是出自本文 ============================================ ...
- Dokcer制作nginx镜像,提交镜像至仓库
生成Dockerfile FROM docker.io/hagaico/centos-base-6.5:latest MAINTAINER yatho yatho@163.com ENV DEBIAN ...
- unity3d的优化场景技术LOD+IOC
一.unity3d的优化场景技术 LOD+IOC 遮挡剔除(occlusion culling)其实就是在摄像机范围内的物体才被渲染出来,没有在视野范围内的,统统关掉渲染,这样能让性能大大提高. I ...
- Unity3D笔记 GUI 三、实现选项卡二窗口
实现目标: 1.使用个性化Box控件 2.个性化Lable控件 3.添加纵向滚动条 4.新建SelectedItem样式 一.最终效果: 二.主要代码 using UnityEngine; using ...