parsererror SyntaxError:JSON中位置0上的意外令牌<

时间:2019-07-15 16:16:05

标签: ajax drupal

submitForm = function (nid, title) {

        var form = $('#candidature')[0];
        var formData = new FormData(form)
        var btn = document.querySelector('#candidature button')
        formData.append('listfields', JSON.stringify(fieldsname))
        formData.append('nid', nid)
        formData.append('title', title)
        formData.append('ntype', 'recrutement_offre')
        console.log(global_json.baseUrl)
        $.ajax({
            url: global_json.baseUrl + "/send-form",
            type: "post",
            data: formData,
            processData: false,
            contentType: false,
            dataType: "json",
            beforeSend: function() {
                btn.innerHTML = '<i class="fa fa-circle-o-notch fa-spin" style="font-size:12px !important"></i>&nbsp;Veuillez patienter...'
            },
            success: function (response) {
                if (response.success) {
                        $('form#candidature').hide();
                        //console.log('success'); 
                }
                showMessage(response, 'candidature'); 
            },
            complete: function (response) {
                btn.innerText = 'Envoyer'
            },
            error: function(jqXHR, textStatus, errorThrown) {
                console.log(textStatus, errorThrown)
                //$('form#candidature').hide();
            }
        })

    }


var fieldsname = {
        "name": "field_field_name_rec",
        "type": "field_field_type_rec",
        "rules": "field_rules_rec",
        "values": "field_values_rec"
    }


$('#formModal').on('shown.bs.modal', function(event) {

0 个答案:

没有答案