jeudi 14 juin 2018

Syntax for an if statement inside an Table Using Jquery/Ajax - ASP.NET MVC

I'm trying make if/elseif statement in my script inside an Table and i did,but i dont why data dont get display, when i check in browser (as you can see in Screenshot number 2). i also debugger statement everything seems fine as you can see in Screenshots number 1. did something wrong with my Syntax?!Can anyone point me in right direction! thanks in advance :)

sc enter image description here


Script:

var ResultString = "";

                $.each(result, function (i, e) {


                    ResultString +=
            '<tr>' +
                     '<td>' + e.Varenummer + '</td>' +
                       '<td>';

                    if (e.Status == "Sendt") {
                    '<i class="fa fa-arrow-right" aria-hidden="true"></i>' +   
                     e.Status

                    }
                    else if (e.Status == "Under behandling") {
                        '<i class="fa fa-check" aria- hidden="true"></i>' + 
                          e.Status
                    }

                          '</td>' +

              '</tr>'


                });


And i have same thing in my Razor page , which working fine and i want same thing in my Script :

  @foreach (var rma in Model)
{
<tr>
 <td>
 @{
if (rma.Status == "Sendt")
 {
 <i class="fa fa-arrow-right" aria-hidden="true"></i> @rma.Status
                                        }
 else if (rma.Status == "Under behandling")
 {
<i class=" fa fa-exclamation-circle" aria-hidden="true"></i> @rma.Status

 }
 else if (rma.Status == "Blive behandlet")
 {

 <i  class="fa fa-check" aria-hidden="true"></i> @rma.Status

 }

}

 </td>
</tr>


}

Aucun commentaire:

Enregistrer un commentaire