如何在select 2的ajax请求中添加主体?

问题描述 投票:0回答:1

我想使用Select2框模仿一个帖子到一个带有纯文本正文的URL(例如“select * from table”),但是我在哪里定义我要发布的正文?

$("#sales_ids").select2({
        placeholder: "Select your Partners",
        multiple: 'multiple',
        ajax: {
            url: 'http://www.google.com/,
            dataType: 'json',
            type: 'post',
            multiple: 'multiple',
            allowclear: 'true',


            processResults: function p(data){

                var mapped = $.map(data, function(obj) {
                    obj.text = obj.text || obj.name;
                    obj.id = obj.id || obj.salesId;
                    return obj;



                })

                return { 
                    results: mapped
                }
drop-down-menu jquery-selectors jquery-select2
1个回答
1
投票
 $.ajax({
    url: 'URL',
    type: 'POST',
    dataType: 'json',
    async: false,

    // Data Goes Here
    data: 'select * from table'
    contentType: 'test/plain'

    success: function (data, textStatus, xhr) {
    // Success Code
    },
    error: function (xhr, textStatus, errorThrown) {
        console.log('Error in Database');
    }
});
© www.soinside.com 2019 - 2024. All rights reserved.