post方式訪問webapi(參數巨大)
- 具體postman設置見圖,其他tabs默認就好。選raw后貼入鍵值對
diagnosisTable=[...]
選post點send即可。
怎么格式化返回的json? 選json
即可
不用postman自己用jQuery實現一個post請求工具
- 讓chrome支持跨域訪問:
chrome圖標上右鍵屬性的目標改成
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir=D:\work\chromeTemp\
- 然后在跨域chrome中訪問如下頁面,注意api改成自己的,內容格式
a=123&b=123
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$('#div1').html('發送成功!');
var a=$('#a').val();
var b=$('#b').val();
$.post(
a,
b ,
function(rlt,status,xhr){
$('#div1').html(rlt);
})
});
});
</script>
api:<input type='text' style='width:1010px' id='a' value='http://localhost:5383/webapi/SysMgr/GetSrvDateTime'/><br> <br>
post內容:<br>
<textarea rows="20" cols="150" id='b'></textarea><br> <br>
<div id='div1'>執行結果</div>
</head>
<body>
<button>發送POST請求</button>