【发布时间】:2012-10-26 00:16:18
【问题描述】:
上下文:我正在尝试编写一个 JavaScript 函数来喜欢 tumblr 上的某个帖子,基于此 link 。我尝试使用 ajax 调用而不是更改 iframe 的源,但它不起作用。当然,更改 iframe 的来源是可行的。
那么,有什么区别导致这不起作用?
$baseUrl = 'http://tumblr.com/like/';
function LikePost( $postID, $reblogUrl )
{
/*
http://www.tumblr.com/<command>/<oauthId>?id=<postId>
<command>: like or unlike
<oauthId>: last eight characters of {ReblogURL}
<postId>: {PostID}
Exemple of Url
http://www.tumblr.com/like/fGKvAJgQ?id=16664837215
*/
$oauthId = $reblogUrl.substring( $reblogUrl.length - 8, $reblogUrl.length);
$likeUrl = $baseUrl + $oauthId + '?id=' + $postID;
$.ajax({
url: $likeUrl,
type:'POST'
});
}
【问题讨论】:
标签: javascript html ajax iframe