> 任意のURLを指定してHTMLを取得する方法
index.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Hello!</title>
</head>
<body>
<input id="url" type="text">
<button id="send">送信</button>
<script src="js/jquery.min.js"></script>
</body>
</html>
index.js
var url = '';
var data = {};
$('#send').click(function(){
url = $('#url').val();
data = {
url: url
};
$.ajax({
url: 'http://localhost/test/',
type: 'GET',
data: data,
success: function(data) {
console.log(data);
}
});
});
PHP
echo file_get_contents($_GET['url']);