【问题标题】:Ajax include fileAjax 包含文件
【发布时间】:2013-05-29 20:31:07
【问题描述】:

我有一个页面 index.php 在 index.php 上,我使用 AJAX 将另一个页面(new_case_form.php)加载到 index.php 到我的 div 中,女巫的 id 是这样的“out”。

function new_case(){
                  if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
                        xmlhttp=new XMLHttpRequest();
                        }
                        else {// code for IE6, IE5
                        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                  }
                  xmlhttp.onreadystatechange=function() {
                  if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                        document.getElementById("out").innerHTML=xmlhttp.responseText;
                  }
            }
            xmlhttp.open("GET","new_case_form.php",true);
            xmlhttp.send();
}

在我的 new_case_form.php 文件中,我包含了一个上传文件,但它不起作用。

如果我只是在我的网络浏览器中直接加载 new_case_form.php 而不通过 index.php,它就可以正常工作。但是,如果我使用 index.php 中的 ajax 调用页面,那么它将无法正常工作。

有什么想法吗?

我不知道你是否回答了这样的问题,但我真的需要让它发挥作用。而且我还没有发现任何其他与此问题有关的问题。也许我用谷歌搜索错了:)

上传脚本来自http://blueimp.github.io/jQuery-File-Upload/

祝你有美好的一天。

瑞典致以最诚挚的问候

【问题讨论】:

标签: php jquery html ajax include


【解决方案1】:

回复文字必须是<php echo "something"; ?>

不知道您的 php 是什么样子...我认为您尝试仅加载计划 HTML...据我所知这是不可能的 :)

【讨论】:

    【解决方案2】:

    为什么不将 jquery 用于 ajax 处理程序?

    $.ajax({url: "new_case_form.php", cache: false}).done(function( html ) { $("#out").append(html);} );

    来源:http://api.jquery.com/jQuery.ajax/

    【讨论】:

    • 谢谢,我希望这对我有帮助,但我不知道如何调用 new_case() 函数?现在我调用函数 New case a href 标记会是什么样子?抱歉这个愚蠢的问题,但我对此很陌生:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-02
    • 2012-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多