-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Support passing url/data object to $.post and $.get #1986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
+1, so frustrating |
+1 |
Ah, the dreaded post to |
I really wish we didn't have the "shortcut" methods at all, they just make things worse. Can you pretend they don't exist? You can also use We're not going to start checking args at runtime and spewing console warnings, period. Take a look at the code for the shortcut methods and see how much code it takes to make them accept an object. If it's not too much we could consider it. |
You'll get no argument from me about those existing, usually wrap $.ajax up in my own facade but that's not really to the point. As long as that stuff exists people will keep using them incorrectly and wasting many hours debugging by accident. I take it you're saying that if I do a PR for this it will be considered? |
+1 |
Yes, be sure to include some unit tests. Also, stop the annoying +1 guys. |
👍 stop all the +1's |
Just to provide a timeline, we'll need a PR in the next week to be able to land this in the next version. We'll also need updates to the docs for $.get and $.post adding a new signature for |
Yeah, I've been trying. I just can't seem to get the async tests passing reliably. I always get between 3 and 7 failing tests and needing to constantly restart php. Been asking around in #jquery-dev and it seems like other people have issues with these as well. I suppose you guys are aware your testing infrastructure is a mess :) Do you have a recommendation on workflow for this type of thing? |
@gmauer You can either ignore these few errors you have or you need to The more elegant solution would be to switch to a server running in Node |
@togakangaroo If you have it that close and some random tests are failing, go ahead with a pull request. I wish our test infra was more robust, but most people get that by mocking the tricky parts. Ajax in particular can't be mocked because often we need to test our workarounds to obscure XHR bugs and the like. |
@togakangaroo Yeah, the built-in PHP web server is a little underpowered. Apache & nginx both work well. The official jQuery docs recommend installing (L|M|W)AMP on your development computer. Personally I've been using a Vagrant VM with nginx. @mzgol Switching over to a Node server would be awesome. Is there a ticket for that? |
I don't believe it is. We haven't really discussed it seriously due to the effort needed. |
Just created: #1999 |
I think the difficulty of getting an environment up and running for jquery development is absolutely a stopper to people contributing. I'm saying the following not in order to complain, but to hopefully help the team see some of the pain points that could be addressed. And also to complain a bit. I'm mostly a js and .net developer working on Windows. I've done php but ages ago and I know some Linux basics but its far from my comfort-zone. Installing php just to run tests was annoying enough, if I had to install and figure out apache setup I definitely would have given up. At the moment I'm about 11 hours into a PR that ultimately changes two lines of code. That's with me coincidentally catching the right people on irc (no way I would have known that Next, I'm a fan of build tools, and building jquery was a breeze. However, testing was not. Testing was not just a matter of I'll also note that I still haven't been able to get the documentation VM running. When I attempt to I realize that it's all a house of cards, but it would seem in order to enable contributions from people who are not in the php space (and also happen to know how to use node/grunt) a significant amount of effort could be justified. Even if the solution is just to package a single VM with all the tools necessary to develop jquery built in. |
@togakangaroo I develop with Windows too. Did you try installing WAMP? |
@togakangaroo thank you for writing this up. Getting started and having a stable setup is the hard part. Now that you've been hazed I hope you'll stay around and continue to contribute, maybe even help us to solve some of these issues. I definitely think the process is harder than it should be, but since we need to actually test in a bunch of real browsers it's never easy. To make things worse, we need a real server to talk to so that we can send back specific requests and test our browser fixes for AJAX patches inside jQuery. Sometimes even the configuration of the web server becomes an issue, we've had some issues moving our tests from Apache to nginx in the past. I do my work on Windows as well. WAMP is definitely the way to go, along with msysgit. I've had my share of troubles with the docs VM as well and at the moment I don't have a working setup either. If you can put together your (untested) suggestions for docs in a pull request we will take it the rest of the way. |
Simplifying the test setup is being discussed in #1999. |
I've just spent yet another 30 minutes helping someone debug this.
The issue:
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
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?The text was updated successfully, but these errors were encountered: