<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>接口测试</title>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
</head>
<body>
<table>
<tr>
<td style="text-align:right">url:</td>
<td><textarea cols="40" rows="10" id="urlData">http://localhost:9415/api/paymentservice/payapply/shsocialinsurance</textarea></td>
</tr>
<tr>
<td style="text-align:right">request Data:</td>
<td><textarea cols="40" rows="10" id="reqData" >{businessType:1}</textarea></td>
</tr>
<tr>
<td style="text-align:right">response Data:</td>
<td id="responseDataTd"></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="测试" οnclick="doTest()"></td>
</tr>
</table>
<script>
function doTest(){
$.ajax({
url: $("#urlData").val(),
data: $("#reqData").val(),
type: "POST",
dataType: "json",
contentType : "application/json;charse=UTF-8",
success: function( result ) {
if(result.code == 0 ){
$("#responseDataTd").css("color","green");
}else{
$("#responseDataTd").css("color","red");
}
$("#responseDataTd").html(JSON.stringify(result));
},
error:function(a,b,c){
$("#responseDataTd").css("color","red");
$("#responseDataTd").html("a:"+JSON.stringify(a)+",b:"+JSON.stringify(b)+",c:"+JSON.stringify(c));
}
});
}
</script>
</body>
<html>
<head>
<meta charset="utf-8">
<title>接口测试</title>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
</head>
<body>
<table>
<tr>
<td style="text-align:right">url:</td>
<td><textarea cols="40" rows="10" id="urlData">http://localhost:9415/api/paymentservice/payapply/shsocialinsurance</textarea></td>
</tr>
<tr>
<td style="text-align:right">request Data:</td>
<td><textarea cols="40" rows="10" id="reqData" >{businessType:1}</textarea></td>
</tr>
<tr>
<td style="text-align:right">response Data:</td>
<td id="responseDataTd"></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="测试" οnclick="doTest()"></td>
</tr>
</table>
<script>
function doTest(){
$.ajax({
url: $("#urlData").val(),
data: $("#reqData").val(),
type: "POST",
dataType: "json",
contentType : "application/json;charse=UTF-8",
success: function( result ) {
if(result.code == 0 ){
$("#responseDataTd").css("color","green");
}else{
$("#responseDataTd").css("color","red");
}
$("#responseDataTd").html(JSON.stringify(result));
},
error:function(a,b,c){
$("#responseDataTd").css("color","red");
$("#responseDataTd").html("a:"+JSON.stringify(a)+",b:"+JSON.stringify(b)+",c:"+JSON.stringify(c));
}
});
}
</script>
</body>
</html>
成功:
失败: