Can I add if or else condition in jquery json response -


my jquery json response adding data table, have use if conditions on day wise. how can use.please suggest example. here have use condition in data.hours.day field. code is:

if (data.hours != null) {     var h = $('#hours').datatable();     $('#hours').datatable().fncleartable();     (var = 0; < data.hours.length; i++) {         h.row.add([            data.hours[i].day,            data.hours[i].open_hr_delivery + " - " + data.hours[i].close_hr_delivery + " , " + data.hours[i].open_hr_delivery1 + " - " + data.hours[i].close_hr_delivery1,             "<a href=\"dspedithour?hourid=" + data.hours[i].dspbusinessmasterid + "\" class=\"btn btn-xs font-blue\"><i class=\"fa fa-edit\"></i> update </a>",           ])        .draw();      } } 

often easier create variables can pass array

     (var = 0; < data.hours.length; i++) {             // example variable passed array             var deliveryhours = data.hours[i].open_hr_delivery +                  " - " +                  data.hours[i].close_hr_delivery +                 " , " + data.hours[i].open_hr_delivery1 +                  " - " + data.hours[i].close_hr_delivery1               h.row.add([             data.hours[i].day,             deliveryhours,//variable above                 "<a href=\"dspedithour?hourid=" + data.hours[i].dspbusinessmasterid + "\" class=\"btn btn-xs font-blue\"><i class=\"fa fa-edit\"></i> update </a>", ]).draw();          } 

using example variable created above should able same thing whatever condition need include


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -