2011-12-13 58 views
1

我想看到的功能和$ .get源()This one

我如何可以继续做到这一点,我下载了Jquery的1.7开发者版本,但不能以任何方式发现里面这个函数...

+0

查看我的回答。也只是在代码中搜索`get`。你会发现它^ _^ – Neal 2011-12-13 20:28:25

回答

5

这些的别名$ .ajax函数。环顾四周线7150在这个文件中

http://code.jquery.com/jquery-1.7.js

jQuery.each([ "get", "post" ], function(i, method) { 
    jQuery[ method ] = function(url, data, callback, type) { 
     // shift arguments if data argument was omitted 
     if (jQuery.isFunction(data)) { 
      type = type || callback; 
      callback = data; 
      data = undefined; 
     } 

     return jQuery.ajax({ 
      type: method, 
      url: url, 
      data: data, 
      success: callback, 
      dataType: type 
     }); 
    }; 
}); 
3

而且在这里你去:-Dhttp://james.padolsey.com/jquery/#v=git&fn=jQuery.get

function (url, data, callback, type) { 
    // shift arguments if data argument was omitted 
    if (jQuery.isFunction(data)) { 
     type = type || callback; 
     callback = data; 
     data = undefined; 
    } 

    return jQuery.ajax({ 
     type: method, 
     url: url, 
     data: data, 
     success: callback, 
     dataType: type 
    }); 
} 
+0

+1为正确的答案,并提供一个很好的链接 – Gabe 2011-12-13 20:32:28

1

查找与此启动代码: 对于jQuery 1.7.1方法开头:

jQuery.each([ "get", "post" ], function(i, method) { 

它只是假冒调用jQuery.ajax