post dynamic
2016-06-20 12:19
246 查看
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="Scripts/jquery-1.8.2.min.js"></script>
<title></title>
</head>
<body>
<input type="button" name="name" value="练习post " id="1"/>
<div id="content">this should be hide</div>
<input type="button" name="name" value="隐藏上文" id="hideContent"/>
<script type="text/javascript">
$("#1").click(function () {
$.ajax({
url: "api/DynamicTest/Test",
type: "POST",
contentType: 'application/json',
data:JSON.stringify({"name":"jim","age":"12"}),
success:function(data)
{
alert(data);
},
dataType:"json"
})
})
//隐藏内容
$("#hideContent").click(function () {
if ($("#hideContent").val() == "显示上文")
{
$("#content").show();
$("#hideContent").val("隐藏上文");
}
else
{
$("#content").hide();
$("#hideContent").val("显示上文");
}
})
</script>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
//using System.Web.Mvc;
using WEBapi.Controllers;
namespace WEBapi.Models
{
public class DynamicTestController : ApiController
{
//
// GET: /DynamicTest/
//[HttpPost]
public string Test( dynamic name)
{
return name.name + "hell";
}
}
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="Scripts/jquery-1.8.2.min.js"></script>
<title></title>
</head>
<body>
<input type="button" name="name" value="练习post " id="1"/>
<div id="content">this should be hide</div>
<input type="button" name="name" value="隐藏上文" id="hideContent"/>
<script type="text/javascript">
$("#1").click(function () {
$.ajax({
url: "api/DynamicTest/Test",
type: "POST",
contentType: 'application/json',
data:JSON.stringify({"name":"jim","age":"12"}),
success:function(data)
{
alert(data);
},
dataType:"json"
})
})
//隐藏内容
$("#hideContent").click(function () {
if ($("#hideContent").val() == "显示上文")
{
$("#content").show();
$("#hideContent").val("隐藏上文");
}
else
{
$("#content").hide();
$("#hideContent").val("显示上文");
}
})
</script>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
//using System.Web.Mvc;
using WEBapi.Controllers;
namespace WEBapi.Models
{
public class DynamicTestController : ApiController
{
//
// GET: /DynamicTest/
//[HttpPost]
public string Test( dynamic name)
{
return name.name + "hell";
}
}
}
相关文章推荐
- c++里面的switch-case问题
- mysql 参数:[read_buffer_size] [sort_buffer_size] [read_rnd_buffer_size] [tmp_table_size]---图解
- Sqoop的那些事
- genymotion的安装
- APP | 001-Android.APP——JavaWeb后台
- 程序猿的情书
- android 自定义PopupWindow,注意的问题
- NYOJ-3 多边形重心问题
- 新版MATERIAL DESIGN 官方动效指南(三)
- 新版MATERIAL DESIGN 官方动效指南(三)
- Android 6.0 申请权限Permission Denial: reading com.android.providers.media.MediaProvider
- 静态分析
- javascript的同源策略
- Java中的ReentrantLock和synchronized两种锁定机制的对比
- gulp布局构建小结
- String类的基本用法与注意点,StringBuffer类的用法
- Spring四种数据源配置
- mysql日志详细解析
- EntityFramework6写的数据访问框架之五事务
- Java编程思想第四版读书笔记——第七章 复用类