javascript调用WebAPI接口登陆和查询示例(基于JQuery)
金蝶云社区-王文亮
王文亮
0人赞赏了该文章 2,474次浏览 未经作者许可,禁止转载编辑于2018年01月10日 19:28:40

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<script type="text/javascript" src="jquery-3.2.1.min.js"></script>
<script type="text/javascript">

$(function(){
$("#testAjax").click(function(){
var json={ "parameters": "[\"59e6f73a471a1b\",\"demo\",\"888888\",2052]"}
json.timestamp=new Date().getTime().toString();
var jsonstr=JSON.stringify(json);
$.ajax({
type: "POST",
url:'http://172.19.66.55:8888/k3cloud/Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc',
contentType: "application/json; charset=utf-8",
data: jsonstr,
success: function(data, textStatus, XMLHttpRequest){

$("#myDiv").html('

'+data+'

');

},
error:function(data){
$("#myDiv").html('

'+data+'

');
}
});

});

$("#testAjax1").click(function(){

var json={ "parameters": "[\"PUR_PurchaseOrder\",\"{\\\"Number\\\":\\\"CGDD000025\\\"}\"]"};

var myDate = new Date();
json.timestamp=myDate.getTime().toString();
var jsonstr=JSON.stringify(json);
alert(jsonstr);
$.ajax({
type: "POST",
url:'http://172.19.66.55:8888/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.View.common.kdsvc',
contentType: "application/json; charset=utf-8",
data: jsonstr,
success: function(data){
$("#myDiv").html('

'+data+'

');

},
error:function(data){
$("#myDiv").html('

'+data+'

');
}
});

});

});

</script>
</head>
<body>
<div id="myDiv">

</div>
<button id="testAjax" type="button">登陆</button>
<button id="testAjax1" type="button">查询</button>
</body>
</html>

test.zip(30.38KB)