[Fixed]-Bootstrap tag-inputs sending POST with spaces

1👍

if you try taking data using form control

<div id="roledata" class="form-group">
    <label for="last_name" class="col-lg-3 control-label">Roles</label>
    <div class="col-lg-8">
        <input type="text" class="form-control" id="roles" placeholder="add role">
    </div>
</div>

js

var roled = {}

$.each($('#roledata').find('.form-control'), function(){
    var field = this.id,
        value = $(this).val()
        data[field] = value
})

data={
    csrfmiddlewaretoken: "{{ csrf_token }}",
    'role' : roled
}

$.ajax({
    type: "POST",
    url: "",
    data: JSON.stringify(data),
    contentType: "application/json",
    dataType: "json",

})

Leave a comment