Skip to content
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

Incorrect (or at least different to jQuery serialization of AJAX data to QueryString) #850

Closed
forbesmyester opened this issue Nov 12, 2013 · 1 comment

Comments

@forbesmyester
Copy link

commented Nov 12, 2013

Using the code:

$.ajax({type:'post',url:'/',data:{$push:{_:[{name:'bob',members:['aaa']}]}}})

Will send the data

%24push%5B_%5D%5B%5D%5Bname%5D=bob&%24push%5B_%5D%5B%5D%5Bmembers%5D%5B%5D=aaa

to the server, which is:

decodeURIComponent("%24push%5B_%5D%5B%5D%5Bname%5D=bob&%24push%5B_%5D%5B%5D%5Bmembers%5D%5B%5D=aaa") == '$push[_][][name]=bob&$push[_][][members][]=aaa'
// true

However doing the same in jQuery will send:

%24push%5B_%5D%5B0%5D%5Bname%5D=bob&%24push%5B_%5D%5B0%5D%5Bmembers%5D%5B%5D=aaa

to the server, which is:

decodeURIComponent("%24push%5B_%5D%5B0%5D%5Bname%5D=bob&%24push%5B_%5D%5B0%5D%5Bmembers%5D%5B%5D=aaa") == '$push[_][0][name]=bob&$push[_][0][members][]=aaa'
// true

I am not entirely sure which is correct, however node-querystring incorrectly parses the Zepto version.

@forbesmyester

This comment has been minimized.

Copy link
Author

commented Nov 12, 2013

I'm going to see if I can fix this issue myself, will hopefully submit a pull request soon.

@ghost ghost assigned mislav Nov 24, 2013

madrobby added a commit that referenced this issue Nov 24, 2013

@mislav mislav closed this in 0cce5f6 Nov 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.