문제

I'm using jQuery multiSelect and want to pass the selections to my update script.

Here's my ajax call

var newnotesecurity = $("#nt_newnotesecurity").serializeArray();

$.ajax({
  url: 'notes-savenewnote.php',
  method: 'POST',
  data: {
    cache: false,
    companyid: companyid,
    entitytype: entitytype,
    entityid: entityid,
    noteinitials: newnoteinitials,
    notetext: newnotetext,
    notetags: newnotetags,
    notesecurity: newnotesecurity
  },
  success: function() {
    // blah
  },
  error: function(){
    // blah
  }
});

nt_newnotesecurity is the multiselect object. Obviously serializeArray is not working for me. It's just my latest attempt to get this working.

I end up passing in this:

notesecurity[0][name]=nt_newnotesecurity&
notesecurity[0][value]=2&
notesecurity[1][name]=nt_newnotesecurity&
notesecurity[1][value]=14

but I'd like to pass in this

nt_newnotesecurity=2&nt_newnotesecurity=14

or I'd be just as content to pass in a single value that I can explode later on, like this

notesecurity=2-14
도움이 되었습니까?

해결책

According to the documentation for the multiselect plugin, just calling val() should get you all the values

var newnotesecurity = $("#nt_newnotesecurity").val();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top