JSFiddle - React, Tailwind, and code Playground
HTML
<input type='text' id='short'>
JavaScript
var $short = $("#short"),
url;
$short.on('paste', function (e) {
var pasteData = e.originalEvent.clipboardData.getData('text');
url = pasteData;
shorten();
});
function shorten() {
$.ajax({
url: '/your_script.php', // Pointed at your php script
type: 'POST', // Or GET - totally optional
data: 'url=' + url, // Your args
dataType: 'text', // Define the type of data you will get back
success: function (data) {
// Data should be your echoed data
// This is faking it
$short.val(data);
}
});
}