How do I make this array of params in a parent param in jQuery?
This is my call as it is :
$(this.form).attr("action",$(this.form).attr("action") + '?' + $("#sortable").sortable('serialize') + "&foo[]=bar");
Which creates this :
importance[]=1&importance[]=2&importance[]=3
My problem is is that I want these params to be apart of card_开发者_StackOverflow中文版signup
So that in card_signup
, I would have importance[1, 2, 3]
How can I alter my original call so that the importance
params will appear within the card_signup param?
You'll need to parse the serialized return to do that.
You could also modify this code to save having to read the attribute twice in your code.
$(this.form).attr("action", function(index, action) {
var values = [],
getKey;
$("#sortable").sortable('serialize').replace(/(\w+?)\[]=(\d+?)/g, function(all, key, number) {
values.push(number);
getKey = key;
});
var cardSignupGetParams = 'card_signup=' + getKey + '[' + values.join(', ') + ']';
return action + '?' + cardSignupGetParams + "&foo[]=bar";
});
jsFiddle.
精彩评论