简体   繁体   中英

jQuery AJAX call doesn't execute success block

I have a Javascript function that does an ajax REST call to a spring controller to grab some stuff from a database and plot it on a map. For some reason the success area of the ajax call isn't executing, but the GET request is returning with a status of 'success'. Is there any reason why my success block wouldn't execute but the complete block would?

query:

$j.ajax({
        url:         url,
        type:      'GET',
        dataType: 'json',
        sucess:   function(json) {
            console.log("getTestData successful");
            boxes = parseJsonForTestData(json);
            //console.log(">> boxes = '" + boxes + "' <<");
        },
        error: function(jqXHR, textStatus, errorThrown) {
            console.log("getTestData failed with textStatus '" + textStatus + "' errorThrown '" + errorThrown + "'");
        },
        complete: function(jqXHR, textStatus){
            console.log("getTestData complete textStatus='" + textStatus + "'");

            if( boxes.length != 0) {
                $j('#results_textfield').text(boxes.length + ' results found');
            }
            else {
                $j('#results_textfield').text(boxes.length + ' result found');
            }
        }
});

parseJsonForTestData:

function parseJsonForTestData(json) {
    console.log(">> In music.js function parseJsonForTestData <<");
    //...abstracted 
}

log:

AJAX call to api/rest/da/getTestData/ music.js (line 310)
GET http://localhost:8080/s2i/api/rest/da/getTestData/

200 OK  39ms    jquery-latest.js (line 6054)

getTestData complete textStatus='success'

Note that none of the console.log statements from the success block or parseJsonForTestData appear in the log file.

Any ideas or advice would be helpful.

you have written sucess: instead of success:

that's why the code is not executed (and maybe you should have some related error in js console)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM