为什么 jQuery $.post 函数不会打印返回值?
首先,我们从代码开始。
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);
});
我正在开发一个小型 Chrome 扩展程序作为 YOURLS 的客户端,并且使用 jQuery $.post
函数与 YOURLS API 进行交互。
在 function(data) {
下,我尝试打印 POST 的返回结果。我尝试过附加,我尝试过警报,我尝试过 document.writing,但没有任何效果。有谁知道出了什么问题吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这通常意味着 ajax 调用失败,添加错误回调以查看问题所在:
That usually means that the ajax call is failing, add an error callback to see what's wrong: