如何从回调函数中获取变量?

时间:2014-07-12 18:50:40

标签: javascript cq5

我使用CQ.HTTP.post来调用某些validation servlet并从true获取验证结果falseservlet

function getValidation(){
var validationResult =false;    
CQ.HTTP.post(
            "/bin/myServlet",
            function(options, success, response) {

                validationResult = response.responseText;           
        },
            {
                "foo": baar
                },
            this, 
            true
        );
    return Boolean(validationResult);};

firebug显示servlet Responsetrue,但函数getValidation()仍然返回false,这意味着变量validationResult不会变化

如何将servletResponse设置为变量validationResult?

0 个答案:

没有答案