I'm getting success result in my ajax code and can return data in my view but i want to sort the results by their id in database,
Example
id => 3 , one
id => 5 , three
id => 2 , five
result should be:
five
one
three
Code
$(document).ready(function() {
$('select[name="selectset"]').on('change', function() {
var id = $(this).val();
if(id) {
$.ajax({
url: '{{ url('admin/selectset') }}/'+encodeURI(id),
type: "GET",
dataType: "json",
success:function(result) {
$.each(result, function(key1, value1) {
var vvvid = value1.id;
// second data
$.ajax({
url: '{{ url('admin/findsubspecification') }}/'+value1['id'],
type: "GET",
dataType: "json",
success:function(data) {
var my_row = $('
var my_html = '{{ Form::open() }}
my_html += '
my_html += '
my_row.html(my_html);
$('div#dataaa').append(my_row);
}
});
// second data
});
}
});
}else{
$('div#dataaa').empty();
}
});
});
PS: what I need is to return vvvid part by their id in database.
Question
How can I sort my output data?