Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.ajax({
- method: 'POST',
- url: '/parts',
- data: $( this ).serialize(),
- dataType: 'json',
- success: function (result) {
- console.log(result);
- details = result.products;
- cars = result.cars;
- models = result.models;
- engines = result.engines;
- years = result.years;
- aggrs = result.aggrs;
- $('#productsTable').html( result.products_html );
- $('#paginate').html( result.paginate );
- $('#productsIds').val( result.products_ids );
- if ( typeof result.cars !== 'undefined' && Object.keys( result.cars ).length && carVal ) {
- $('#formSelectCar').html( '<option value="0">Марка</option>' );
- $.each(result.cars, function( index, value ) {
- // console.log(index, value);
- option = '<option value="' + value.id + '">' + value.name + '</option>';
- $('#formSelectCar').append( option );
- });
- }
- if ( typeof result.models !== 'undefined' && Object.keys( result.models ).length && modelVal ) {
- console.log('models', result.models);
- if($('#formSelectCar').val() != 0) {
- carId = $('#formSelectCar').val();
- console.log('each models', carId);
- $('#formSelectModel').html( '<option value="0">Модель</option>' );
- $.each(result.models[carId], function( index, value ) {
- console.log(index, value);
- option = '<option value="' + value.id + '">' + value.name + '</option>';
- $('#formSelectModel').append( option );
- });
- }
- }
- if (result.years) {
- $('#formSelectYear').html( '<option value="0">Год</option>' );
- $.each(result.years, function (index, value) {
- option = '<option value="' + value.id + '">' + value.name + '</option>';
- $('#formSelectYear').append( option );
- });
- }
- if (result.aggrs) {
- $('#formSelectAggr').html( '<option value="0">Код</option>' );
- $.each(result.aggrs, function (index, value) {
- option = '<option value="' + value.id + '">' + value.name + '</option>';
- $('#formSelectAggr').append( option );
- });
- }
- if (result.engines) {
- $('#formSelectEngine').html( '<option value="0">Код</option>' );
- $.each(result.engines, function (index, value) {
- option = '<option value="' + value.id + '">' + value.name + '</option>';
- $('#formSelectEngine').append( option );
- });
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement