1
0
mirror of synced 2024-11-26 14:56:07 +03:00

Merge pull request #756 from socialceramics/url-function-with-arguments

Ajax `url` option (when function) now called with same arguments and context as `data` option
This commit is contained in:
Igor Vaynberg 2013-01-31 14:31:32 -08:00
commit 300e99fcd5

View File

@ -287,16 +287,18 @@ the specific language governing permissions and limitations under the Apache Lic
requestSequence += 1; // increment the sequence requestSequence += 1; // increment the sequence
var requestNumber = requestSequence, // this request's sequence number var requestNumber = requestSequence, // this request's sequence number
data = options.data, // ajax data function data = options.data, // ajax data function
url = options.url, // ajax url string or function
transport = options.transport || $.ajax, transport = options.transport || $.ajax,
traditional = options.traditional || false, traditional = options.traditional || false,
type = options.type || 'GET'; // set type of request (GET or POST) type = options.type || 'GET'; // set type of request (GET or POST)
data = data ? data.call(this, query.term, query.page, query.context) : null; data = data ? data.call(this, query.term, query.page, query.context) : null;
url = (typeof url === 'function') ? url.call(this, query.term, query.page, query.context) : url;
if( null !== handler) { handler.abort(); } if( null !== handler) { handler.abort(); }
handler = transport.call(null, { handler = transport.call(null, {
url: ((typeof options.url === 'function')?options.url():options.url), url: url,
dataType: options.dataType, dataType: options.dataType,
data: data, data: data,
type: type, type: type,