如果用户从 div 中的任何下拉列表中更改条目,SalePlugin
那么它将需要获取所有选定的值并将其传递给 POST。
应该怎么做?
$('.SalePlugin > *').live('change', function(){
var SalePluginData = $(this).closest('.SalePlugin').find('select').serialize();
$.post(host + '/ajax/file.php', { Data: SalePluginData }, function(data){
console.log(data);
});
});
HTML
<div class='SalePlugin'>
<ul>
<li>
<select name='something[]'>
<option value='one'>One</option>
<option value='two'>Two</option>
</select>
</li>
</ul>
<ul>
<li>
<select name='something[]'>
<option value='one'>One</option>
<option value='two'>Two</option>
</select>
</li>
</ul>
<ul>
<li>
<select name='foo[]'>
<option value='one'>One</option>
<option value='two'>Two</option>
</select>
</li>
</ul>
</div>