未捕获的ReferenceError:未定义ajax(匿名函数)

时间:2013-12-25 01:18:34

标签: javascript ajax prototypejs

new Ajax.Request('http://habbo.com.br/client', {
    onComplete: function (x) {
        var sso1 = x.responseText.match(/"sso.ticket" : "(.+)"/)[0].split('"')[3];
    }
});

当我使用此代码时,会出现以下错误:

  

未捕获的ReferenceError:未定义Ajax(匿名函数)

我不明白为什么!有谁知道这个问题?

1 个答案:

答案 0 :(得分:0)

您必须请求ajax

try {
    var ajaxRequest; // The variable that makes Ajax possible!

    try {
        // Opera 8.0+, Firefox, Safari
        ajaxRequest = new XMLHttpRequest();
    } catch (e) {
        // Internet Explorer Browsers
        try {
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                // Something went wrong
                alert("Your browser broke!");
                return false;
            }
        }
new Ajax.Request('http://habbo.com.br/client', {
                onComplete: function (x) {
                    var sso1 = x.responseText.match(/"sso.ticket" : "(.+)"/)[0].split('"')[3];
                }
            });
    }
        } catch (e) {
            alert("This won't show up, so no error!");
        }