JQuery .submit不起作用(奇怪的问题)

时间:2016-12-19 15:02:51

标签: javascript jquery html twitter-bootstrap

我在该模型中使用bootstrap模型,可以使用Ajax提交一些图像。

问题是我何时使用这个简单的JQuery代码

页面刷新,没有提醒或提交。

每当我从模特按钮中删除<td>$data.='时 jquery代码有效,但我无法删除它们,因为程序中的所有html代码都被分配给变量,例如&#34; $数据=&#39。 &#34;

JQuery代码

$(document).ready(function(){
    $(".Doc_image_upload").submit(function(e) {
        e.preventDefault();  
        alert('test');
    });   
});

模型按钮

$data.='<td>
            <button class="unassigned remove'.$shipment['id'].'" 
                    id="shipmentid" data-toggle="modal"   data-target="        
                    .bd-example-modal-lg2'.$shipment['id'].'"
                    value1="'.$shipment['id'].'">More</button> 
        </td></tr></form>';   ?>

形式

<div class="collapse" id="uploadimage<?php echo $shipment['id']; ?>">
    <div class="well well2">
        <form  class="Doc_image_upload"  enctype="multipart/form-data" value1="<?php echo $shipment['id']; ?>">
            <label>Upload Document:</label><br/>
            <input type="file" name="doc_image" > <br/>
            <select name="doctype" required>
                <option value="">Select Type</option>
                <?php echo Doc_type() ?></select></label> <br/>
            <label>Document Number:</label>
            <input type="text" name="docnumber" placeholder="Enter Document number " pattern='[0-9]{10}' title="Please enter 10 digits" required>  <br/>
            <label>Document Expire Date:</label><br/>

            <input type="submit" name="submit" class="uploadDoc" value1="<?php echo $shipment['id']; ?>">
            <input type="hidden" name="customer_id" value="<?php echo $customer_id; ?>">
            <input type="hidden" name="shipmentid" value="<?php echo  $shipment['id']; ?>">
        </form>
    </div>
</div>

我该如何解决?

///// ------------------------------------------ - ///////////// 添加更多代码

  <form  method="post" id="employee_form">

                <div class="col-lg-12 col-md-12 col-small-12">
                    <div style="    margin-bottom: 100px;" class="tbl-content">
                        <div  class="tbl-header">
                            <table cellpadding="0" cellspacing="0" border="0">
                                <thead>

                                <tr>
                                    <th><input type="checkbox" id="select_all"/>Select</th>
                                    <th>Airwaybill</th>
                                    <th>USD Amt</th>
                                    <th>Wt</th>
                                    <th>Description</th>
                                    <th>Consignee</th>
                                    <th>Orig</th>
                                    <th>Dest</th>
                                    <th>Prod Cd</th>


                                    <th>Status</th>

                                    <th>more</th>
                                </tr>
                                </thead>
                            </table>
                        </div>


                        <div class="assign_to">
                         <label>Assign to</label>
                          <select name="Employee" class="Employee" >
                                <option value="0">Select User</option>
                              <?php echo load_Employee() ; ?>
                           </select>
                             <input type="submit" id="assign" class="unassigned"  value="Assign">
                        </div>

                               <?php
                        $data .='       
                    <table cellpadding="0" cellspacing="0" border="0" class="results_unassigned" id="check">

                        <tbody>

                        '; while($shipment = sqlsrv_fetch_array($get_customer_rule,SQLSRV_FETCH_ASSOC)) {

            $data .='          <tr>

                            <td>
                               <input type="checkbox" class="checkbox"  name="shipment_id[]" value="'.$shipment['id'].'">
                            </td>
                          <td>
                            '.$shipment['awbno'].'

                          </td>                             

                          <td>
                            '.$shipment['shipvalue'].'
                          </td>
                          <td >
                            '.$shipment['weight'].'
                          </td>
                          <td>
                            '.$shipment['contentdesc'].'
                          </td>
                          <td>
                            '.$shipment['consigneename'].'
                          </td>
                          <td>
                            '.$shipment['origin'].'
                          </td>
                          <td>
                            '.$shipment['destination'].'
                          </td>
                          <td>
                              '.$shipment['prodcontentcd'].'
                          </td>
                          <td>
                            '.$shipment['status'].'
                          </td>';


         $data.='<td>
            <button class="unassigned remove'.$shipment['id'].'" 
                    id="shipmentid" data-toggle="modal"   data-target="        
                    .bd-example-modal-lg2'.$shipment['id'].'"
                    value1="'.$shipment['id'].'">More</button> 
        </td></tr></form>';   ?>

补充

如果我使用jquery显示页面

,则不会发生此问题
$('whatevet').html(data);

0 个答案:

没有答案