javascript - 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”,但它仍然没有显示任何内容。
谁能告诉我出了什么问题?
解决方案
使用扩展名重命名包含 PHP 代码的文件.php
,因为您的 Web 服务器未配置为生成 PHP 进程*.html
文件。
推荐阅读
- python - 全世界的总体预期寿命是多少?(与 numpy )
- maven - Kotlin top level method not visible between modules in mixed Kotlin + Java Maven project
- python - 使用熊猫时,如何按其值而不是标签删除一行?
- installation - 亚行安装失败:INSTALL_FAILED_BLOCKED_CROSS_DOWN
- c# - .NET Core 上的 Windows/WSL 互操作在 windows 上是否有 AF_UNIX 支持
- angular - 使用惰性加载就地绑定 ngFor
- javascript - 如何在 VueJs 项目中导入单个 Lodash 函数?
- php - Apache 重写规则导致 JS 和 CSS 文件的“重定向过多”
- tsql - T-SQL:如果不存在则插入
- python - 熊猫在唯一值上迭代一列并获取另一列的值