Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.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
can';我看不到使用ajax和php从服务器响应的html代码_Php_Javascript_Html_Ajax - Fatal编程技术网

can';我看不到使用ajax和php从服务器响应的html代码

can';我看不到使用ajax和php从服务器响应的html代码,php,javascript,html,ajax,Php,Javascript,Html,Ajax,1.Jquery脚本与Ajax $('#location').change(function(){ var l = $('#location :selected').val(); $.ajax({ type:'POST', url : 'function/get_location.php', dataType:'html', data : { loc : l}, success: function(data)

1.Jquery脚本与Ajax

$('#location').change(function(){
    var l = $('#location :selected').val();
    $.ajax({
    type:'POST',
        url : 'function/get_location.php',
        dataType:'html',
        data : { loc : l},
        success: function(data){
            $('#advertise_record').html(data);
        }   
    });
});
我想在我的网页中看到名为#advision_record的blog div中显示的来自服务器的响应的html代码。但是当右键单击查看源代码时,我在博客中没有看到html代码,但结果显示在这里

2.html代码

<div id="advertise_record"></div>

我需要服务器响应显示在这里的结果。 它会显示结果,但当我右键单击“查看源代码”时,我没有看到该代码

3。get_location.php

<?php

    include_once (dirname(__FILE__). '/dbconfig.php');

    define('ADVERTISE_DIRECTORY','../advertise/');

    if(isset($_POST['loc'])) $loc = mysql_real_escape_string($_POST['loc']);

    switch($loc){
        case 0 : $sql = 'SELECT * FROM tblads';break;
        case 1 : $sql = 'SELECT * FROM tblads WHERE loc_id="'.$loc.'"'; break;
        case 2 : $sql = 'SELECT * FROM tblads WHERE loc_id="'.$loc.'"'; break;
        case 3 : $sql = 'SELECT * FROM tblads WHERE loc_id="'.$loc.'"'; break;
        default:"";
    }
    ?>
    <table border="1" cellpadding="5" cellspacing="5" width="850px;">
        <tbody>
            <tr>
                <td><input type="file" name="filename" id="filename" class="text"/></td>
                <td><label class="title">Name :</label><input type="text" name="ads_name" id="ads_name" class="text" style="width:150px;"></td>
                <td><label class="title">URL :</label><input type="text" name="url" id="url" class="text" style="width:150px;"/></td>
                <td><input type="button" name="update" id="update" class="button button_update"/></td>
            </tr>
    <?php
    $output = mysql_query($sql) or die(mysql_error());
    while($row = mysql_fetch_array($output)){
        ?>
        <tr>
            <td colspan="3" align="center">
                <div style="width: 700px;height: auto;overflow-x: scroll;">
                    <img src='<?php echo ADVERTISE_DIRECTORY.$row['image_name']?>' alt='<?php echo $row['ads_name'];?>' />  
                </div>
            </td>
            <td align="center"><a href='#tab-advertise?edit=<?php echo $row['ads_id']?>' >Edit</a></td>
        </tr>   
        <?php
    }
?>  
        </tbody>
    </table>    

姓名:
网址:
'alt='''/>

那么我的代码出了什么问题。非常感谢您抽出时间回答。

您不会在源代码中看到任何最初不存在的内容。如果您想查看ajax调用返回的html,请查看浏览器开发工具中的network/net选项卡。此外,您正在为图像设置内容类型,这是不正确的,因为您的输出是html表。

为什么您的MIME类型设置为
image/jpeg
?如果您不想输出HTML代码,那么您应该删除
header()
函数,或者将其设置为
text/HTML
。好的!我删除了它,但它仍然不起作用。还有一个我想显示图像,但图像不显示。为什么?谢谢你的回答。在这个表中,我也想显示图像,你可以在get_location.php中看到我的代码,对吗?但是图像没有显示在我的网页中为什么?@noeurphreak如果图像没有显示,那么路径(即
src
属性)是错误的。好的!现在我可以将图像加载到我的页面了。另一个问题是,当我右键单击查看源代码时,我没有看到在我的页面中显示该图像的html代码。为什么?谢谢你抽出时间。。