Site Notice
hello, world
Difference between revisions of "Short url"
From Project-EPB Commons
([InPageEdit] 没有编辑摘要) |
([InPageEdit] 没有编辑摘要) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
<pre id="url"></pre> | <pre id="url"></pre> | ||
− | <input placeholder="https://wjghj.cn" value="https://wjghj.cn" id="request"></input> | + | <input placeholder="https://wjghj.cn" value="https://wjghj.cn" id="request" style="width:20em"></input> <button onclick="start()">生成短网址</button> |
− | <button onclick="start()"> | ||
<script> | <script> | ||
Line 9: | Line 8: | ||
$.ajax({ | $.ajax({ | ||
url: 'https://common.wjghj.cn/api.php', | url: 'https://common.wjghj.cn/api.php', | ||
+ | type: 'post', | ||
+ | dataType: 'json', | ||
data: { | data: { | ||
− | url: $('#request').val() | + | action: 'shortenurl', |
+ | url: $('#request').val(), | ||
+ | format: 'json' | ||
}, | }, | ||
− | |||
− | |||
success: function(data) { | success: function(data) { | ||
$('#url').html(data.shortenurl.shorturl); | $('#url').html(data.shortenurl.shorturl); |
Latest revision as of 01:32, 3 March 2020
<html>
<pre id="url"></pre> <input placeholder="https://wjghj.cn" value="https://wjghj.cn" id="request" style="width:20em"></input> <button onclick="start()">生成短网址</button>
<script> function start() {
$.ajax({ url: 'https://common.wjghj.cn/api.php', type: 'post', dataType: 'json', data: { action: 'shortenurl', url: $('#request').val(), format: 'json' }, success: function(data) { $('#url').html(data.shortenurl.shorturl); } });
} </script> </html>