<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style></style>
    <script>
        (function ($) {
            $(document).ready(function () {
                $('#handle').click(function () {
                    var consultant_id = $('#consultant option:selected').val();
                    $.ajax({
                        type: 'POST',
                        url: '{{ url }}/wp-admin/admin-ajax.php/',
                        data: 'action=update_consultant&id={{ id }}&consultant_id=' + consultant_id,
                        success: function (data) {
                            if (data.code == 2000) {
                                alert('提交处理成功');
                            } else {
                                alert('提交处理失败');
                            }
                        }
                    });
                });
            });
        })(jQuery);
    </script>
</head>
<body>
<div>
    <ul>
        <li>楼盘名/房源名：{{ house_result.name }}</li>
        <li>用户：{{ house_result.phone }}</li>
        <li>预约时间：{{ house_result.date }} {{ house_result.time }}</li>
    </ul>
</div>
<label for="consultant"></label>
<select id="consultant">
    {% for consultant in consultant_result %}
    <option value="{{ consultant.id }}"
    {% if(house_result.consultant_id==consultant.id) %}selected="selected"{% endif %}>{{ consultant.display_name }}</option>
    {% endfor %}
</select>
<button id="handle">提交处理</button>
</body>
</html>