为什么无法识别 Ajax?

在这段代码中,Ajax是不被识别的,但是其他jQuery方法或选择器却工作得很好。

new Ajax.Request(form.action,{
      method: 'POST',
      postBody: params,
      onSuccess: function(response) {
         var responseText = response.responseText || '[]';
         var json = responseText.evalJSON();
         if (json.success) {
             alert("json.sucess")
            onSuccessfulLogin(form.j_username.value);
         }
         else if (json.error) {
             alert("json.error")
            $("form").enable(document.ajaxLoginForm);
         }
         else {
            alert("responseText"+responseText);
            $("form").enable(document.ajaxLoginForm);
         }
      }
   });

我需要添加其他库或JAR吗?我使用的是jQuery1.7.2。

And what about this:

$.ajax({
    url: url,
    type: "post",
    data: params,
    success: function (response, textStatus, jqXHR) {
        var responseText = response.responseText || '[]';
        var json = responseText.evalJSON();
        if (json.success) {
            alert("json.sucess")
            onSuccessfulLogin(form.j_username.value);
        }
        else if (json.error) {
            alert("json.error")
            $("form").enable(document.ajaxLoginForm);
        }
        else {
            alert("responseText"+responseText);
            $("form").enable(document.ajaxLoginForm);
        }
    },
    error: function (jqXHR, textStatus, errorThrown) {
    },
    // callback handler that will be called on completion
    // which means, either on success or error
    complete: function () {
    }
});

Ajax jQuery documentation here: http://api.jquery.com/jQuery.ajax/

This could be for a couple of reasons. First, try including a more recent version of jQuery - 3.2.1. Second, make sure that you aren't including the library twice anywhere. Also, possibly try a request in this form:

$("button").click(function(){
   $.ajax({url: "demo_test.txt", success: function(result){
      $("#div1").html(result);
   }});
});

Check out documentation here: https://www.w3schools.com/jquery/jquery_ajax_intro.asp

I hope this helps!