POST localhost:5000/registrar
{
"enrollId": "jim",
"enrollSecret": "6avZQLwcUe9b"
}
如何在javascript文件中使用它?是否使用JSON或JQuery?以及如何在.html中调用request函数?
为此使用jQuery:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
和通话功能
$(document).ready(function(){
$.post('localhost:5000/registrar', {
"enrollId": "jim",
"enrollSecret": "6avZQLwcUe9b"
}, function(serverResponse){
//do what you want with server response
})
})
同样,没有速记来处理错误:
$.ajax({
type: "POST",
url: 'localhost:5000/registrar',
data: {
"enrollId": "jim",
"enrollSecret": "6avZQLwcUe9b"
},
success: function(){$('#register').html('<h1>Login successfull</h1>');},
error: function(){$('#register').html('<h1>Login error</h1>');},
dataType: dataType
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句