gpt4 book ai didi

javascript - JS Click 上的 PHP 函数?

转载 作者:行者123 更新时间:2023-12-02 17:48:47 24 4
gpt4 key购买 nike

我有一个按钮,可以将链接复制到剪贴板,但它已使用 bit.ly 缩短了。目前我已经有了它,因此它在页面加载时创建了 bit.ly 链接,这看起来有点困惑,所以我只是想知道如何让它仅在复制到剪贴板时才执行此操作?

var client = new ZeroClipboard( document.getElementById("copy-link"), {
moviePath: "ZeroClipboard.swf"
} );

client.on( "load", function(client) {
// alert( "movie is loaded" );

client.on( "complete", function(client, args) {
// `this` is the element that was clicked
$.gritter.add({
// (string | mandatory) the heading of the notification
title: 'Link Copied',
// (string | mandatory) the text inside the notification
text: 'Link has been copied to your clipboard'
});
$('[data-toggle="dropdown"]').parent().removeClass('open');
} );
} );

这是我的 PHP

<?php

$url = Router::url(null, true);
if ($this->UserAuth->isLogged()) {
$url .= '?shareref=' . $var['User']['id'] . '';
}
$shortlink = bitly_v3_shorten($url, 'bit.ly');

?>

最佳答案

JQuery Ajax 将是您的最佳选择:http://api.jquery.com/jquery.ajax/ - 创建它,以便在您单击按钮时运行 PHP。

关于javascript - JS Click 上的 PHP 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21555822/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com