1

I need to parse with ajax to php file the following form. I can't use use serialize().

< input type="checkbox" name="Filter[0]" value="Train" id="Filter">
< input type="checkbox" name="Filter[1]" value="Airplane" id="Filter1">

I was thinking

var Filter = $('#Filter').val();
.....
data: {..., ..., Filter:Filter}

it doesn't work. Any Idea?

9
  • 1
    Is there a reason for not using serialize? Commented Sep 11, 2013 at 19:55
  • yes because I have also pagination {page:page, ..., Filter:Filter} Commented Sep 11, 2013 at 19:56
  • 1
    So just do form.serialize() + '&page=' + page; Commented Sep 11, 2013 at 19:57
  • It makes sense I will try. Commented Sep 11, 2013 at 19:59
  • why do your name attributes have indices? Commented Sep 11, 2013 at 19:59

1 Answer 1

1
var filters = $("input[name^='Filter']");
var filterObj = {};
filters.each(function(index){
    filterObj['filter' + index] = this.value;
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.