راکت

خطای ajax bad request 400 در وردپرس

بدون پاسخ

سلام
من یک افزونه نوشتم که کاربران امکان امتیاز دهی به برگه ها رو دارن کدهای من به صورت زیر هست.
کد html:

<div class="star-rating">
<span class="postid" post-id="52"></span>
<span class="score-bg"></span>
<div class="scores">
    <?php for ($i = 1; $i <= 5; $i++): ?>
        <div class="score" data-score="<?php echo $i; ?>">
            <span class="scoreAbsolute"></span>
        </div>
    <?php endfor; ?>
</div>

کد جی کوئری

jQuery(document).ready(function ($) {
$(function () {
    $(".post-score").click(function () {
        var score = $(this).attr('data-score');
        var post = $('.postid').attr('post-id');
        $.ajax({
            url: post_score.ajaxscript,
            method: 'POST',
            data: {
                'action': 'submit_score',
                'postid': post,
                'Score': score,
            },
            success: function (data) {
                console.log(data);
            }, error: function (errorThrown) {
                alert('nok');
            }
        });
    });
});
});

کد php

add_action('wp_ajax_submit_score', 'submit_score');
    add_action('wp_ajax_nopriv_submit_score', 'submit_score');

    function submit_score()
    {
        if (isset($_POST['action'])) {
    //something
        }
        wp_die();
    }

هنگام ارسال وقتی در کنسول لاگ میگیرم قبل از $.ajax همه موارد لاگ میشن اما متاسفانه خطای 400 میده و error اجرا میشه.

ثبت پرسش جدید

پاسخ‌ها

0

هنوز پاسخی ثبت نشده

اولین نفری باشید که به این پرسش کمک می‌کند و مسیر حل مشکل را باز می‌کند.

اولین پاسخ را بنویسید

شاید پاسخ شما همین‌جا باشد

برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام