【问题标题】:weird response from server with ajax来自服务器的奇怪响应与 ajax
【发布时间】:2013-07-03 21:05:42
【问题描述】:

编辑: 显然,他们将此添加到免费托管页面以防止滥用。但我通过添加“退出”摆脱了它;最后。 结束编辑

我创建了一个名为 ajax 的函数,因此我不必在任何需要它的地方编写代码,而且效果很好。 但现在作为响应,我总是得到我期望的数据作为响应加上这个:

<!-- Start of StatCounter Code for Default Guide -->

<script type="text/javascript">

var sc_project=6961715; 

var sc_invisible=1; 

var sc_security="1ca8e3ee"; 

</script>

<script type="text/javascript"

src="http://www.statcounter.com/counter/counter.js"></script>

<noscript><div class="statcounter"><a title="tumblr stats"

href="http://statcounter.com/tumblr/" target="_blank"><img

class="statcounter"

src="http://c.statcounter.com/6961715/0/1ca8e3ee/1/"

alt="tumblr stats"></a></div></noscript>

<!-- End of StatCounter Code for Default Guide -->

我用 if (xmlhttp.readyState == 4 && xmlhttp.status == 200){alert(xmlhttp.responseText);}检查数据

我确定代码没问题,因为它与我之前使用的代码相同。这里是:

function ajax(adress, thenDo)
{
    var xmlhttp;

    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            thenDo(xmlhttp.responseText);
        }
    }

    xmlhttp.open("GET",adress,true);
    xmlhttp.send();
}

有谁知道如何摆脱这个?

我刚刚检查了它在该服务器上我的每个页面的底部。 (我在hourb托管上使用免费托管)

【问题讨论】:

  • 如果您以前从未见过 StatCounter 的东西,您可能需要确保您的共享主机提供商没有将它放在那里。
  • 好吧,我之前注意到了它,因为我在浏览器中查看了源代码或在该托管站点上使用了 ajax,但我认为它不应该存在。但我想我找到了将票发送到支持的地方。有没有人种过这样的东西?
  • exit; 添加到您的 ajax 页面以尝试缓解它。可能无济于事,但仍然
  • 退出命令有效!谢谢人

标签: php ajax hosting


【解决方案1】:

这几乎肯定是由您的托管服务提供商添加的,它的使用是帮助您保持免费托管的因素之一。

从好的方面来说,他们只会为某些内容类型添加此内容,因此您可能需要检查您的数据是否以 text/xml 的形式返回。如果是,那么我建议直接联系他们,并询问是否可以更改配置以排除 XML 文件。

【讨论】:

  • 这是一个php页面,发送响应,它可能认为它是php或html。
  • 您应该能够使用浏览器的调试工具并监控网络请求进行查找。如果它以 text/html 的形式返回,那么只需添加 header('Content-Type: text/xml'); 就足够了。
  • 在一些免费主机上添加 exit();在脚本的末尾抑制计数器。
猜你喜欢
  • 2023-03-12
  • 1970-01-01
  • 1970-01-01
  • 2012-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-08
相关资源
最近更新 更多