Reputation: 11
First, let's start with the code.
chrome.tabs.getSelected(null, function(tab) {
tabURL = tab.url;
$.post("http://s.mxtm.me/yourls-api.php",
{ signature: "XXXXXXXXXX",
action: "shorturl",
url: tabURL,
format: "simple"
},
function(data) {
$("body").append(data);
});
I'm working on a little Chrome extension as a client for YOURLS, and I'm using the jQuery $.post
function to interact with the YOURLS API.
Under function(data) {
I'm attempting to print the return from my POST. I've tried appending, I've tried alerting, I've tried document.writing, but nothing works. Does anyone have any idea of what is wrong?
Upvotes: 0
Views: 414
Reputation: 51461
That usually means that the ajax call is failing, add an error callback to see what's wrong:
$.post(
"http://s.mxtm.me/yourls-api.php",
{ signature: "XXXXXXXXXX", action: "shorturl", url: tabURL, format: "simple" },
function(data) { $("body").append(data); }
).error(function(xhr,error,ex) { alert("error"); });
Upvotes: 0