0

コードが実際に何をするのかを調べるために、コードをバックトラックしています関数に入りましたが、関数getResults()がここでどのようsuccess()にトリガーされるのか理解できません。私を案内してください。前もって感謝します。

function getResults(u) {
//alert("Inside get results");
    $.ajax({
        dataType: "jsonp", 
        url: u,
        success: function(res) {                                                    
        alert("Inside success");                                                        
              $("#status").hide();                                                      
              if (res.data.length) {
                  // do something                                                       
            } else {
              // do something else
            }; 
        } 
    });
}
4

2 に答える 2

3

非同期関数です。その概念に慣れていない場合は、最初に読んでおくことをお勧めします。

于 2013-02-28T16:15:01.873 に答える
0

success is simply what happens when the data at the other end of the URL comes back.

FYI, you might want to look into the shorthand getJSON

http://api.jquery.com/jQuery.getJSON/

于 2013-03-01T02:09:14.663 に答える