Created
October 31, 2017 19:48
-
-
Save egyjs/fa3bca2ab47ee6dcb932fdd81dc75d04 to your computer and use it in GitHub Desktop.
shorte.st api javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="text" maxlength="512" id="searchTxt" class="searchField"/> | |
<input type="button" value="Get Value" onclick="cut(searchTxt.value)"> | |
<script> | |
function cut(myurl){ | |
$.ajax({ | |
url:"https://api.shorte.st/v1/data/url", | |
type:"put", | |
async:true, | |
crossDomain:true, | |
dataType:"json", | |
data:{urlToShorten: myurl}, | |
accepts:{ | |
"*": "*/*", | |
text: "text/plain", | |
html: "text/html", | |
xml: "application/xml, text/xml", | |
json: "application/json, text/javascript" | |
}, | |
headers: {'public-api-token':'b86592121c395b7494c792805e736b09'}, | |
success: function(result) { | |
console.log(result); | |
}, | |
error: function(request,msg,error) { | |
console.log(error); | |
} | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment