0

Как ориентироваться в src папке проекта jquery?
Где я могу найти конкретно этот jQuery.get метод?:

/src/ajax.js #L815

    getScript: function( url, callback ) {
        return jQuery.get( url, undefined, callback, "script" );
    }

Тот что мне удалось найти выполняет совсем другую задачу:

/src/core.js #L58

    // Get the Nth element in the matched element set OR
    // Get the whole matched element set as a clean array
    get: function( num ) {
        return num != null ?

            // Return just the one element from the set
            ( num < 0 ? this[ num + this.length ] : this[ num ] ) :

            // Return all the elements in a clean array
            slice.call( this );
    }

Версия Jquery 1.12.4

2
  • 2
    Так вот же, буквально рядом: jQuery.each( [ "get", "post" ], function( _i, method ) {jQuery[ method ] = function( url, data, callback, type ) { ... - github.com/jquery/jquery/blob/…
    – Yaant
    19 сен 2019 в 14:53
  • Спасибо, не ожидал найти его в таком виде. 19 сен 2019 в 14:58

1 ответ 1

1

Как и сказал Yaant метод get определяется сразу после getScript. Там же с помощью метода each определяется и post метод.

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;
        }

        // The url can be an options object (which then must have .url)
        return jQuery.ajax( jQuery.extend( {
            url: url,
            type: method,
            dataType: type,
            data: data,
            success: callback
        }, jQuery.isPlainObject( url ) && url ) );
    };
} );

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.