Javascript 尝试调用AJAX函数时出现NS\u错误\u XPC\u错误\u转换\u JS

Javascript 尝试调用AJAX函数时出现NS\u错误\u XPC\u错误\u转换\u JS,javascript,ajax,nserror,Javascript,Ajax,Nserror,在Wordpress中关闭Thickbox时,我试图首先将通过Thickbox选择的图像添加到屏幕(工作),然后运行一个小AJAX例程来更新数据库中的一个选项(导致错误) 但是,我得到了错误NS\u error\u XPC\u BAD\u CONVERT\u JS:无法转换JavaScript参数,我不知道为什么 目前,我所做的只是测试AJAX函数是否正在被pcick化,因此PHP函数所做的就是echo'Working!',所以我相当肯定问题出在JS中的某个地方,而不是PHP返回的内容。然而,注

在Wordpress中关闭Thickbox时,我试图首先将通过Thickbox选择的图像添加到屏幕(工作),然后运行一个小AJAX例程来更新数据库中的一个选项(导致错误)

但是,我得到了错误
NS\u error\u XPC\u BAD\u CONVERT\u JS:无法转换JavaScript参数
,我不知道为什么

目前,我所做的只是测试AJAX函数是否正在被pcick化,因此PHP函数所做的就是
echo'Working!',所以我相当肯定问题出在JS中的某个地方,而不是PHP返回的内容。然而,注释掉AJAX调用并不意味着错误不会出现

有人有什么解决问题的建议吗?我现在不知道该去哪里看。谢谢

jQuery(document).ready(function($){

    window.send_to_editor = function(html){

        /** Grab the image URL and image ID */
        var image_url = $('img', html).attr('src'),
            classes = $('img', html).attr('class'),
            id = classes.replace(/(.*?)wp-image-/, '');

        /** Add the imgae ID to a hidden field, so that it can be saved */
        $('#office-image input#image-id').val(id);

        /** Remove the Thickbox */
        tb_remove();

        /** Place the image src in the hidden image, and then show the image */
        $('#office-image img#image-preview').attr('src', image_url);
        $('#office-image img#image-preview').css('display', 'block');
        $('#office-image img#image-preview').css('margin-bottom', '5px');

        /** Check to see if the user is editing an Office, and if they are, update the Image in the database */
        if($('#dd-options-edit-office-page').length) {

            /** Set the params for passing to the AJAX function */
            data = {
                security: $('input#_wpnonce', '#dd-options-edit-office-page'),
                action: 'update-office-image'
            };

            $.post('admin-ajax.php', data, function(response){

                alert(response);

            });

        }

    }

});
谢谢,

看看这个:

data = {
                security: $('input#_wpnonce', '#dd-options-edit-office-page'),
                action: 'update-office-image'
            };
data.security
包含jQuery对象,无法发送此对象

我猜您希望发送输入值:

data = {
                security: $('input#_wpnonce', '#dd-options-edit-office-page').val(),
                action: 'update-office-image'
            };

非常感谢,我担心会是那样愚蠢的事情!!