响应时未调用回调
callback not invoked on response
我有这样的UI代码
<div class="panel-heading">
Log Messages <button type="button" class="btn btn-primary" onclick="onrefresh()">Fetch New Messages</button>
</div>
所涉及的js是
var dt = $(document).ready(function() {
var hostName = 'http://127.0.0.1:7101';
...some code
});
function onrefresh(){
console.log("he viti");
xmlhttp = new XMLHttpRequest();
var url = "http://127.0.0.1:7101/LogAnalyzer-RESTWebService-context-root/rest/v1/LogMessagesVORest";
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Content-type", "application/vnd.oracle.adf.action+json");
xmlhttp.onreadystatechange = function() {//Call a function when the state changes.
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
alert('we are back');
location.reload();
}
}
xmlhttp.send(JSON.stringify(parameters));
}
回调不会在onrefresh方法中发生。然而,我注意到在顶部部分的方法涉及jquery在那里工作得很好。
try this
request.addEventListener('load', function(event) {
if (request.status >= 200 && request.status < 300) {
console.log(request.responseText);
} else {
console.warn(request.statusText, request.responseText);
}
});
相关文章:
- 成功回调永远不会被JSONP请求调用
- 为什么(如何)'这'从函数内部调用回调时发生更改
- 如何在点击超链接时调用fullcalendar回调
- 在初始函数完成之前调用回调函数
- 未为路由器应用程序调用Node.Js的回调
- 对中的函数调用进行排序是回调的唯一方法
- Node.js exec调用从不调用回调
- 如何从参数数组中调用回调
- 当我的单元测试失败时,回调被调用了两次
- 回调函数(如afterMove)不被调用
- 如何使用jQuery等待来自回调的异步调用
- FireFox webrtc createoffer,没有任何回调调用
- 如何识别函数是作为方法调用还是作为回调调用
- jquery方法不是从angular回调调用的
- 从回调调用asyncwait
- 你可以使用PhoneGap和iOS从本地代码(而不是回调)调用javascript函数吗?
- Backbone model.fetch()回调(调用setTimeout)中的作用域问题
- React.js:你用一个不可调用的回调调用了' setState '
- 从图表.js选项回调调用 TypeScript 函数
- 如何将js函数从异步调用转换为回调调用