响应时未调用回调

时间:2016-09-23 19:17:31

标签: javascript jquery

我有像

这样的ui代码
<div class="panel-heading">
    Log Messages&nbsp;&nbsp;&nbsp; <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的方法在那里工作正常。

1 个答案:

答案 0 :(得分:0)

试试这个

#include <iostream>
#include <stack>
#include <string>

struct Bracket {
    Bracket(char type, int position):
        type(type),
        position(position)
    {}

    bool Matchc(char c) {
        if (type == '[' && c == ']')
            return true;
        if (type == '{' && c == '}')
            return true;
        if (type == '(' && c == ')')
            return true;
        return false;

    }

    char type;
    int position;
};


int main() {
    std::string text;
    getline(std::cin, text);
    int z;

    std::stack <Bracket> opening_brackets_stack;
    for (int position = 0; position < text.length(); ++position) {
        char next = text[position];

        if (next == '(' || next == '[' || next == '{') {
            opening_brackets_stack.push(Bracket(next,0));
        }

        if (next == ')' || next == ']' || next == '}') {

            if(Bracket.Matchc(next) == false || opening_brackets_stack.empty() == false)
            {
               z = position;
            }

            else
            {
                opening_brackets_stack.pop();
            }

        }
    }

    if (opening_brackets_stack.empty())
    {
        std::cout << "Success";
    }

    else
    {
        std::cout << z;
    }
    return 0;
}