首页 > 解决方案 > ajax调用的html中的PHP不起作用

问题描述

所以这是我的ajax调用

function insertModal(link)
{
$.ajax({
    url: link,
    cache: false,
    dataType: "text",
    success: function(data) {
        $("#modalInput").html(data);
    },
    error: function (request, status, error) {
        alert(request.responseText);
    }
});
}

这是我的 ajax 调用的 html 文件

        <form>
            <div class="modal-content">
                <h3>Input Car</h3>
                <div class="row">
                    <div class="col s12 select-container">
                        <i class="material-icons prefix light-green-text text-darken-1">date_range</i>
                        <select id="th_car_out">
                            <?php
                                include 'script/year.php';
                            ?>
                        </select>
                        <label>Choose Car Year</label>
                    </div>
                </div>
            </div>
        </form>

除了 PHP 脚本,一切都运行良好,表单显示等。

我已经尝试将我的 php 脚本“include”更改为一些基本的 php 脚本 echo“option”,甚至写简单的 echo“hi”,但它仍然没有显示任何内容。

谁能告诉我出了什么问题?

标签: javascriptphphtmlajax

解决方案


使用扩展名重命名包含 PHP 代码的文件.php,因为您的 Web 服务器未配置为生成 PHP 进程*.html文件。


推荐阅读