最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery AJAX call doesn't execute success block - Stack Overflow

programmeradmin0浏览0评论

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 plete 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 + "'");
        },
        plete: function(jqXHR, textStatus){
            console.log("getTestData plete 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 plete 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.

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 plete 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 + "'");
        },
        plete: function(jqXHR, textStatus){
            console.log("getTestData plete 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 plete 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.

Share Improve this question asked Jun 4, 2012 at 15:43 Hunter McMillenHunter McMillen 61.6k25 gold badges124 silver badges176 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

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)

发布评论

评论列表(0)

  1. 暂无评论