Mr world wide
Mr world wide

Reputation: 4814

How to combine jquery response with php

success: function (response) {
$.each(response, function(k, student) {
<td>'+student.test_status+'</td>

In the above <td> i am getting value as 1 or 2 i want to show that if the value is 1 show message if 2 show another message like that i can do this with php i want to combine with jquery how can i do that..?

    <td>
    <?php if('+student.test_status+' == 1) { ?>
    <span style="color:green"><?php echo "GD completed"; ?></span>
    <?php } else if('+student.test_status+' == 2) { ?>
    <span style="color:green"><?php echo "PI Completed"; ?></span>
    <?php } else { ?><span style="color:red"><?php echo "Not Started"; ?></span>
    <?php } ?>
    </td>

I want solution something like this.

Upvotes: 1

Views: 70

Answers (1)

ben
ben

Reputation: 470

try this make sure js is in the same file of the php follow the below codesnippt

$.each(response, function(i, item) {
            $('<tr>').html(
                $('td').text(item.rank),
                $('td').text(item.content),
                $('td').text(item.UID)
            ).appendTo('#records_table');

        });

you need to append to the records_table in the HTML markup

<div id="records_table"></div>

Upvotes: 3

Related Questions