简体   繁体   中英

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM