在PHP内部和jQuery函数中使用变量jquery

时间:2017-02-04 02:06:12

标签: php jquery syntax

如果您看到此功能<?= input_txt('+order_id+') ?>
有jquery变量,但jquery发送错误

function order_status(type, order_id) {
    var value = type.value;

    var info = document.getElementById("cancel_id_" + order_id).value;
    document.getElementById("my_cancel_info").innerHTML = "Determine the reason for cancellation of the order number " + info;
    document.getElementById("cancelled_info").innerHTML = '<?= input_txt('+order_id+') ?>';




    if (value == 2) {
        $('#order_cancelled').modal('show');
    }
}

1 个答案:

答案 0 :(得分:2)

首先需要了解PHP和javascript的执行顺序。 PHP呈现在服务器端,而javascript呈现在客户端。我建议您查看http://api.jquery.com/jquery.ajax/,您可以通过AJAX将javascript变量传递给PHP脚本,然后返回结果。