更新时间:2023-02-23 22:33:13
$(function() {
$( "#selectable" ).selectable({
stop: function() {
var result = $( "#select-result" ).empty();
$( ".ui-selected", this ).each(function() {
var index = $( "#selectable li" ).index( this );
// send an AJAX request to a PHP file
$.get('myphpfile.php', {
selectedIndex: index
}, function(data) {
// do stuff with the results from PHP
});
});
}
});
});
编辑
要通过按钮执行此操作
$(function() {
$( "#selectable" ).selectable();
$("submit[name=Submit1]").click(function() {
var index = $( "#selectable li" ).index( $("#selectable") );
$.get('myphpfile.php', {
selectedIndex: index
}, function(data) {
// do stuff with the results from PHP
});
});
});