最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

400 Bad Request - Post to admin-ajax.php

programmeradmin2浏览0评论

Any ideas as to why I'm getting a 400 Bad Request from this?

JS

$(document).on('keyup', '#typeahead_input', function() {

    let typeahead_query = $('#typeahead_input').val();
    let post_data = {
        'data' : typeahead_query,
        'action' : 'typeahead_function'
    };

    $.ajax({
        method: "POST",
        url: '/wp-admin/admin-ajax.php',
        data: post_data,
        dataType: "html",
        success: function(ret){
            console.log(ret)
        }
    });
});

PHP

add_action( 'wp_ajax_typeahead_function', 'typeahead_function' );

function typeahead_function() {
    return 456;
}
发布评论

评论列表(0)

  1. 暂无评论