HTML代码
API源码
<?php header('Content-type:application/json; charset=utf-8'); !empty($_GET['url']) ? $url = $_GET['url'] : exit(json_encode(['code'=>202,"msg"=>"参数错误"],JSON_UNESCAPED_UNICODE)); $api = file_get_contents('https://umapi.top/api/dy.php?url='.$url); $data = json_decode($api,true); echo json_encode($data,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
JS代码
$(document).ready(function(){ $('#button').click(function (){ var text = $('#url').val(); if (text == '') { alert('域名不能为空'); return false; } $.ajax({ url:'api.php', type:'get', dataType:'json', data: {url:text}, beforeSend: function(){ $("#load").html(''); $("head").prepend(meta); }, success:function(data){ if (data.code == 200) { var mkhtml = '解析结果'; $(".watermark").html(mkhtml); $("#load").empty(); }else{ alert(data.msg); $("#load").empty(); } } }); }); });
HTML、API、JS都给你们了,剩的就靠自己了,可以的人应该一看就懂得,分享给大家学习。