jquery .ajax demo 传参数给后台@RequestBody @RequestParms

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Blockchain Platform</title>
</head>
<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
	
	function funcAAA(){
		//alert("hellos");
		// window.open("./demo.html","_parent");
		
		console.log("request...");
		$.ajax({
			url:"/api/xxx/ccc",
			type:"POST",
			dataType:"json",
			async:false,
			data:{
			},
			success:function(data){
				alert(data.code);
				alert("hello");
			},
		});
	}
	
	
    function funcBBB(){
        console.log("request...");
        $.ajax({
            url:"/api/xxx/bbb",
            type:"POST",
            dataType:"json",
            async:false,
            data:{
                "id":"id001",
		"name":"name001"
            },
            success:function(data){
                if("200"==data.code)
				{
				    alert(data.data);
				}else{
                    alert(data.code);
				}
            },
        });
    }

    function funcCCC(){
        console.log("request...");
        $.ajax({
            url:"/api/xxx/aaa",
            type:"POST",
            dataType:"json",
            async:false,
			contentType:"application/json;charset=utf-8",
            data: JSON.stringify({"id":"id0003","name":"name0003"}),
            success:function(message){
                if("200"==message.code)
                {
                    alert(message.data);
                }else{
                    alert(message.code);
                }
            },
			error:function(message){
                $("request-process-patent").html("fail to post");
			}
        });
    }
</script>
<body >
	<div style="text-align: center;">
		<table >
			<tr>
				<th>uu</th>
				<th><button οnclick="funcAAA()">click</button></th>
			</tr>
			<tr>
				<th>uu</th>
				<th><button οnclick="funcBBB()">issue</button></th>
			</tr>
			<tr>
				<th>uu</th>
				<th><button οnclick="funcCCC()">issueShow</button></th>
			</tr>
		</table>
	</div>
</body>
</html>


@RestController
@RequestMapping("/api/xxx")
public class AdminController{}

@RequestMapping(value="/aaa",method= RequestMethod.POST)

    public JsonResult userMgr(@RequestBody Map<String,String> map){
        String id=map.get("id");
        String name=map.get("name");
}

@RequestMapping(value="/bbb",method= RequestMethod.POST)
    public JsonResult usrAdmin(@RequestParam String id, @RequestParam String name){
        logger.info("assetIssue parameters:"+ id+":"+name);
}




评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值