删除附加到ajax请求返回的结果中的自动生成的广告脚本

Khu*_*shi 4 ajax jquery ads

我的网站托管在somee.com上。

我已经使用JQuery发送Ajax请求。

在每个ajax请求中,返回的结果将附加以下文本。

"<!--SCRIPT GENERATED BY SERVER! PLEASE REMOVE--> 
<center><a href="http://somee.com">Web hosting by Somee.com</a></center> </textarea>
</xml></script></noframes></noscript></object></layer></style></title></applet> 
<script language="JavaScript" 
src="http://ads.mgmt.somee.com/serveimages/ad2/WholeInsert4.js"></script>
<!--SCRIPT GENERATED BY SERVER! PLEASE REMOVE-->"
Run Code Online (Sandbox Code Playgroud)

例如,如果成功调用ajax,服务器将返回以下字符串:“无效的用户名和/或密码”

然后我得到以下字符串:

"Invalid Username and/or Password <!--SCRIPT GENERATED BY SERVER! PLEASE REMOVE-->
 <center><a href="http://somee.com">Web hosting by Somee.com</a></center> </textarea>
</xml></script></noframes></noscript></object></layer></style></title></applet> 
<script language="JavaScript" 
src="http://ads.mgmt.somee.com/serveimages/ad2/WholeInsert4.js"></script> 
<!--SCRIPT GENERATED BY SERVER! PLEASE REMOVE-->"
Run Code Online (Sandbox Code Playgroud)

现在,我将这个字符串与另一个字符串进行比较,因此比较返回false,因为此字符串包含附加的文本。

因此,我的网站无法正常运行。

编辑

我数了。字符并尝试使用.slice(0, -no. of characters in advertisement)。如果服务器返回字符串,则可以正常工作。但是在服务器返回时不起作用,'JSON'因为在ajax调用中我们必须声明dataType:'json',添加广告脚本后,结果将不再是json对象。因此,没有调用成功,因此我没有得到输出。

所以,现在我的问题是:如果服务器JSON + String在AJAX调用上返回,则在客户端,我只想delete the String part获取JSON对象,以便AJAX调用成功返回,而不是失败/错误。(我知道附加字符串包含的字符数。)

Gre*_*reg 5

@Kushi,我想如果您要问这个问题,那么您首先会在常规页面上摆脱自动脚本而没有任何回发。你能告诉我你是怎么做到的吗?

谢谢

我只是想出了办法,所以我为其他会寻找答案的人编辑了答案。终于没那么糟糕了:)

<script>
    $(document).ready(function () {
        $("div[style='opacity: 0.9; z-index: 2147483647; position: fixed; left: 0px; bottom: 0px; height: 65px; right: 0px; display: block; width: 100%; background-color: #202020; margin: 0px; padding: 0px;']").remove();
        $("div[style='margin: 0px; padding: 0px; left: 0px; width: 100%; height: 65px; right: 0px; bottom: 0px; display: block; position: fixed; z-index: 2147483647; opacity: 0.9; background-color: rgb(32, 32, 32);']").remove();
        $("div[onmouseover='S_ssac();']").remove();
        $("center").remove();
        $("div[style='height: 65px;']").remove();
    });
</script>
Run Code Online (Sandbox Code Playgroud)

它对我有用:)