由ajax调用的html中的PHP无法正常工作

问题描述:

So this is my ajax call

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

And this is my html file which called by 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>

Everything is working good, the form show up etc, except the PHP script.

I already try changing my php script "include" to some basic php script echo "option" or even write simple echo "hi", but it still did not show anything.

Can anyone tell me what went wrong ?

所以这是我的ajax调用 p>

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

这是我的html文件,由ajax调用 p>

 &lt; form&gt; 
&lt; div class =“modal-content”&gt  ; 
&lt; h3&gt;输入Car&lt; / h3&gt; 
&lt; div class =“row”&gt; 
&lt; div class =“col s12 select-container”&gt; 
&lt; i class =“material  -icons前缀light-green-text text-darken-1“&gt; date_range&lt; / i&gt; 
&lt; select id =”th_car_out“&gt; 
&lt;?php 
 include'scrip / year.php';  
?&gt; 
  &lt; / select&gt; 
&lt; label&gt;选择Car Year&lt; / label&gt; 
&lt; / div&gt; 
&lt; / div&gt; 
&lt; / div&gt; 
&lt; / form&gt; 
  代码>  pre> 
 
 

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

我已经尝试更改我的PHP脚本“include” 一些基本的php脚本echo“选项”甚至写简单的回音“hi”,但它仍然没有显示任何内容。 p>

谁能告诉我出了什么问题? p> \ n div>

Rename the file containing PHP code with the extension .php, as your web server is not configured to make PHP process *.html files.

are you shure that your file is with .php extension?

you can put html in your php file, but in html file is not possible to put php expression.