gpt4 book ai didi

javascript - Facebook 评论插件在创建评论时返回 500 错误

转载 作者:行者123 更新时间:2023-12-02 23:49:54 27 4
gpt4 key购买 nike

我在 MVC 环境中使用 Facebook 评论插件,当我添加评论时,它崩溃并在控制台中出现 500 错误。在页面加载期间加载所有评论时,我没有收到错误。但是,注释已成功添加到 URL,因此在创建 create 后会发生错误。

这是相关代码,已尽可能清理(JavaScript 在底部)

<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.2"></script>

<div class="w-container">
<div id="allPosts">
@foreach (var post in ViewBag.Posts.Data)
{
<div class="w-row">
<div class="w-col w-col-12 w-col-medium-12 w-col-small-12">
<p>@post.MetaDescription ...</p>
</div>
</div>
<div class="w-row post-button">
<div class="w-col w-col-3 w-col-small-12">
<input type="hidden" class="postBodyHtmlHidden" value="@post.Body" />
<input type="hidden" class="postSlug" value="@post.Slug" />
<div class="fb-comments" style="display: none;" data-href="http://localhost:36998/blog#@post.Slug" data-numposts="5"></div>
<input type="button" value="Continue Reading" class="btn btn-primary continue-reading-btn" />
</div>
</div>
}
</div>

<div id="postBody" style="display:none;">
<div class="w-row">
<div class="w-col w-col-12">
<input type="button" value="Back" onclick="AllPosts()" class="btn btn-primary" />
<br />
<div id="postHmtlDiv">

</div>
<div id="postCommentDiv">

</div>
</div>
</div>
</div>
</div>

<script>
$('.continue-reading-btn').on("click", function () {
var postHtml = $(this).closest('.w-row').find('.postBodyHtmlHidden').val();
var postSlug = $(this).closest('.w-row').find('.postSlug').val();
var postComment = $(this).closest('.w-row').find('.fb-comments').html();

$('#allPosts').css("display", "none");
$("#postHmtlDiv").html(postHtml);
$('#postCommentDiv').html(postComment);
$('#postCommentDiv .fb-comments').removeAttr('style');
$("#postBody").fadeIn("slow");

});

function AllPosts() {
$('#postBody').css('display', 'none');
$('#postHmtlDiv').html('');
$('#allPosts').fadeIn('slow');
};

</script>

我不知道如何调试这个。

错误看起来像这样(同样,在添加评论后):

enter image description here

最佳答案

答案很简单!该代码无效!

<div class="fb-comments" style="display: none;" data-href="http://localhost:36998/blog#@post.Slug" data-numposts="5"></div>

data-href 属性 不能是本地主机。我将其更改为其他内容并且成功了!

关于javascript - Facebook 评论插件在创建评论时返回 500 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55693814/

27 4 0
文章推荐: javascript - 如何使
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com