Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ajax调用的html中的PHP不起作用_Javascript_Php_Html_Ajax - Fatal编程技术网

Javascript ajax调用的html中的PHP不起作用

Javascript ajax调用的html中的PHP不起作用,javascript,php,html,ajax,Javascript,Php,Html,Ajax,这是我的ajax调用 function insertModal(link) { $.ajax({ url: link, cache: false, dataType: "text", success: function(data) { $("#modalInput").html(data); }, error: function (request, status, error) { alert(request.res

这是我的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);
    }
});
}
这是我的html文件,由ajax调用

        <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”,但它仍然没有显示任何内容


有人能告诉我出了什么问题吗?

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

您的文件是否具有.PHP扩展名


您可以在php文件中放入html,但在html文件中无法放入php表达式。

通过“它仍然没有显示任何内容”,您的意思是显示php代码还是从不更新
#modalInput
?。此外,
success
error
complete
回调自jQuery 3.0以来被替换,以支持
done
fail
always
。显示Yes。我试着把这个放在上面,但仍然没有显示hi。你能发布你的web服务器配置吗?可能以
.html
结尾的文件会被发送到客户端,而不会首先由PHP处理。尝试使用扩展名
.php
重命名它。它可以正常工作。谢谢你应该把它作为一个答案。我把它从.html改为.php,结果很好,非常感谢。