php - $.get 不返回 html

标签 php javascript jquery ajax facebook

我的简单代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script src="jquery.js"></script>
<script type="text/javascript">
$(function(){
$.get("http://www.facebook.com",function(data){
alert(data);});

});</script></head>

 <body>
</body>
</html>

它应该提醒 Facebook 内容,但它没有这样做

更新

现在我正在使用 php

<?php
 $str=file_get_contents("http://www.facebook.com");
    echo strip_tags(htmlspecialchars($str)); 
?>

为什么它不删除标签?

最佳答案

如果您在服务器端使用 php。您可以创建一个返回 html 的服务,使用:

$html = file_get_contents('http://www.facebook.com');

ASP.NET:

using(WebClient client = new WebClient()) 
{
    string html = client.DownloadString("http://www.facebook.com'");
}

关于php - $.get 不返回 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10737402/

相关文章:

PHP显示存储的时间数据,并在考虑不同时区的同时存储时间数据

javascript - 在 Javascript 中引用 Go 数组

jquery/jqtouch getJSON 调用导致无限循环?

javascript - Safari 300ms 延迟 Apple 设备

php - MySQL PHP 表更新/POST 不工作

PHP 和 Smarty 执行

php - PHP 中的空 MySQL 查询结果

javascript - 更新继承的属性

javascript - 多个 html 页面的 Gulp-compile-handlebars?

javascript - 每当数据库发生问题时更新 yii2 grid