Skip to content

Support passing url/data object to $.post and $.get #1986

@togakangaroo

Description

@togakangaroo

I've just spent yet another 30 minutes helping someone debug this.

The issue:

$.post( {url: '/foo', data: bar})

generates a post request not at all to /foo. The reason is of course that this is not the signature of the method. The correct signature is

$.post('/foo', bar)

The problem is that $.ajax does accept things in the former format and its oh so easy to forget which is which. (And of course it's jquery standard to allow configuration objects in most places.) Of course when you make the mistake, it is very difficult to figure out what is going on as it will still generate a post request, just to the current page with an [object Object] parameter making you question your sanity.

I must have spent days over the years debugging this and helping others debug it.

So, feature request: Can $.post and $.get please support passing of a configuration object as the first parameter? If not, can passing an object at least generate a console.warn to hint at what might be going on?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions