Skip to content

HTTP quick methods for put, patch, head, delete, options for Ajax #4639

@terremoth

Description

@terremoth

Description

Create quick methods for the others HTTP verbs/methods:

jQuery.each( [ "put", "patch", "head", "delete", "options" ], function( i, method ) {
	jQuery[ method ] = function( url, data, callback, type ) {

		if ( jQuery.isFunction( data ) ) {
			type = type || callback;
			callback = data;
			data = undefined;
		}

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

Adding something like this will help a lot of people to write a clean code when we speak about ajax methods to make great readable ajax code.

It will look like this:

$.get(...),
$.post(...),
$.put(...),
$.patch(...),
$.head(...),
$.delete(...),
$.options(...),

Version proposal: 4.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions