weixin_33697898 2017-01-29 11:06 采纳率: 0%
浏览 16

序列化AJax中的数据

I having trouble for adding a multiple Sub Author in my form, I have a form that you can add a sub author. The code works if I only submit one sub author but if multiple sub author the codes not working. Here's the code of my text box in FormAddBook.

<input type="text" class="form-control" placeholder="Sub Authors" name="SubAuthors[]"  maxlength="50" />

And when you want to add another sub author, text box will appear when yun click the Add Sub Author with the same name of textbox.

The codes work when one sub author only but if multiple sub authors the codes not working. Here's the code of my jquery.

$.ajax({ 
      type: 'POST', 
      url: 'proc/exec/exec-insert-book.php',
      data: $('#FormAddBook').serialize(), 
});


Does the Serialize cannot recognize the another text box?
Sorry for my bad english.
Here's the HTML Form code.

  <form id="FormAddBook">
  <div class="modal-body">
    <div class="row">

        <div class="col-lg-6 hide" >
            <label>Accession No:</label>
            <div class="form-group">
                <input type="text" class="form-control" placeholder="Accession No" name="AccessionNo" readonly/>
            </div>
        </div>

        <div class="col-lg-12">
            <div class="form-group">
                <label>ISBN:</label>
                <input type="text" class="form-control" placeholder="ISBN" name="BookISBN"  maxlength="20" />
            </div>
        </div>

        <div class="col-lg-6">
            <div class="form-group">
                <label>Date Book Added:</label>
                <div  id="DateBookAdded" class="input-group">
                  <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                  <input type="text" class="form-control" placeholder="Date Book Added" name="DateBookAdded" readonly/>
                </div>
            </div>
        </div>

        <div class="col-lg-6">
            <div class="form-group">
                <label>Archived Date Extension:</label>
                <div  id="BookAuthLast" class="input-group">
                  <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                  <input type="text" class="form-control" placeholder="" name="ArchivedDateExt" readonly/>
                </div>
            </div>
        </div>


        <div id="subauthcont">
        <div class="subAuthors col-lg-12">
            <div class="form-group">
                <label>Sub authors:</label>
                <div class="input-group">
                    <input type="text" class="form-control" placeholder="Sub Authors" name="SubAuthors[]"  maxlength="50" />
                    <span class="input-group-btn" disabled>
                        <button id="btnAddSubAuth" class="btn btn-info" type="button" ><i class="fa fa-user" aria-hidden="true"></i></button>
                    </span>
                </div> 
            </div>
        </div>
        </div>

        <div class="col-lg-8">
            <div class="form-group">
                <label>Subject:</label>
                <select class="form-control" name="Description">
                    <option>Generalities</option>
                    <option>Philosophy and Psychology</option>
                    <option>Religion</option>
                    <option>Social Science</option>
                    <option>Languages</option>
                    <option>Science</option>
                    <option>Technology</option>
                    <option>Arts and Recreation</option>
                    <option>Literature</option>
                    <option>Geography and History</option>
                </select>
            </div>
        </div>

        <div class="col-lg-4">
            <div class="form-group">
                <label>Status:</label>
                <select class="form-control" name="Status" readonly>
                    <option>Available</option>
                </select>
            </div>
        </div>
    </div>
  </div> 
  <div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    <button id="btnSave2" type="submit" class="btn btn-primary asd">Save</button>

  </div>
  </form>
</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度