JQuery Serialize无法在Internet Explorer上运行

时间:2017-09-19 14:10:22

标签: javascript jquery html serialization

出于某种原因,当我尝试向fullcalendar添加句点时,我的页面上的序列化不适用于表单,但仅适用于Internet Explorer。它返回一个空字符串。是否有解决方法或替代序列化?

JS:

function addPeriod() {
    $.post({
        url: "{{ path('authorizedAbsence_period_create') }}",
        data: $('form[name="staffbundle_absence_period"]').serialize(),
        dataType: 'json',
        ...
    });
}

HTML

<table>
    <form id="staffbundle_absence_period" name="staffbundle_absence_period" method="post" action=""></form>
    <tbody><tr class="sf_admin_form_row sf_admin_text ui-corner-all ">
    <td><label for="staffbundle_absence_period_type">Tipo:</label></td>
    <td>
        <div class="content"><select id="staffbundle_absence_period_type" name="staffbundle_absence_period[type]"><option value=""></option><option value="choices.absence_type.vacation">Férias</option><option value="choices.absence_type.training">Formação</option><option value="choices.absence_type.medical">Baixa médica</option></select></div></td>
</tr>
    <tr class="sf_admin_form_row sf_admin_text ui-corner-all ">
    <td><label for="staffbundle_absence_period_user">Colaborador:</label></td>
    <td>
        <div class="content"><select id="staffbundle_absence_period_user" name="staffbundle_absence_period[user]" style="width: 100%;"><option value=""></option><option value="25">Alberto Conde</option>...</select></div></td>
</tr>
<tr class="sf_admin_form_row sf_admin_text ui-corner-all ">
    <td></td>
    <td>
        <div class="content"><div id="staffbundle_absence_period_start" style="display: none;"><select id="staffbundle_absence_period_start_day" name="staffbundle_absence_period[start][day]"><option value="1">01</option>...</select><select id="staffbundle_absence_period_start_month" name="staffbundle_absence_period[start][month]"><option value="1">01</option>...</select><select id="staffbundle_absence_period_start_year" name="staffbundle_absence_period[start][year]"><option value="2012">2012</option>...</select></div></div></td>
</tr><tr class="sf_admin_form_row sf_admin_text ui-corner-all ">
    <td></td>
    <td>
        <div class="content"><div id="staffbundle_absence_period_end" style="display: none;"><select id="staffbundle_absence_period_end_day" name="staffbundle_absence_period[end][day]"><option value="1">01</option>...</select><select id="staffbundle_absence_period_end_month" name="staffbundle_absence_period[end][month]"><option value="1">01</option>...</select><select id="staffbundle_absence_period_end_year" name="staffbundle_absence_period[end][year]"><option value="2012">2012</option>...</select></div></div></td>
</tr>
</tbody></table>

1 个答案:

答案 0 :(得分:0)

我猜测你的问题可能出现在HTML本身上......我认为<form>不应该是<table><tbody>的子元素,<tr>等,请尝试将<form>元素移出<table>