2011-02-24 20 views

回答

1

我用这个方法,只有你可以看到更多的岗位:

Using jQuery, how do you mimic the form serialization for a select with multiple options selected in a $.ajax call?

var mySelections = []; 
     $('#mySelect option').each(function(i) { 
       if (this.selected == true) { 
         mySelections.push(this.value); 
       } 
     }); 


    $.ajax({ 
     type: "post", 
      url: "http://myServer" , 
      dataType: "text", 
      data: { 
       'service' : 'myService', 
       'program' : 'myProgram', 
     'selected' : mySelections 
       }, 
      success: function(request) { 
       result.innerHTML = request ; 
     } 
    }); // End ajax method 
+0

如何推动这两个选项的文字和选择价值。 – user581805 2011-02-24 13:25:55

+0

mySelections.push({text:$ this.text(),value:$ this.val()); – 2011-02-24 13:29:17

+0

谢谢,我会试试这个。 – user581805 2011-02-24 16:40:58