我已在文件中使用了所选函数,但当我尝试访问此函数时出现错误,如下所示:
TypeError: $(...).ajaxChosen is not a function
这是我正在使用的代码:
$.post( woocommerce_admin_meta_boxes_variations.ajax_url, data, function ( response ) {
$( '#bto_config_group_inner .bto_groups' ).append( response );
$( "#bto_ids_" + bto_groups_metabox_count ).chosen();
$( "#bto_ids_" + bto_groups_metabox_count ).ajaxChosen( {
method: 'GET',
url: woocommerce_admin_meta_boxes.ajax_url,
dataType: 'json',
afterTypeDelay: 100,
data: {
action: 'woocommerce_json_search_products',
security: woocommerce_admin_meta_boxes.search_products_nonce
}
}, function (data) {
var terms = {};
$.each( data, function (i, val) {
terms[i] = val;
} );
return terms;
} );
$( 'input#_per_product_pricing_bto' ).change();
$( '#bto_product_data' ).unblock();
$( '#bto_product_data' ).trigger( 'woocommerce_bto_component_added' );
} );
return false;
} );
最佳答案
你有包含https://github.com/meltingice/ajax-chosen吗?在你的项目中?看起来它在您的代码中不可见。
关于javascript - 我在使用选定的 jquery 函数时遇到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39273621/