php - Jquery form.submit 在 IE9 中不发布任何内容

标签 php javascript jquery internet-explorer

我几天来一直在寻找问题的解决方案,但还没有找到解决我的问题的解决方案。我希望这里有人能够帮助我或为我指明正确的方向。 我的问题如下: 我正在使用 jquery (1.9.0) 和 jquery-ui (1.10.1)。我有一个带有表单的页面,应该将其发布到 php 脚本以将数据添加或更新到我的数据库中。在 FF 中,甚至在 IE 8 和 IE 10 中,一切都工作正常。但在 IE9 中,数据只是未提交:var_dump'ing $_POST 数组给我一个空数组,没有发布任何内容。

这是代码(我将提交要点:

    <form name="documents" id="documents" method="POST" action="inc/add_new_doc.php">
        <table class="invoer" align="left">
        <tr>
            <th align="left" colspan="8"><h2>Please fill out all fields</h2></th>
        </tr>
        <tr>
            <td align="right">Originator:</td>
            <td colspan="2"><select name="company_id" id ="company_id"><?php echo getCompanyList(0); ?></select></td>
            <td>Originator document number:</td>
            <td colspan="2"><input name="docnrsupplier" id="docnrsupplier" type="text" size="30" tabindex="2" /></td>
            <td>Document category:</td>
            <td><select name="doccat_id" id ="doccat_id"><?php echo getDocCatList(0); ?></select></td>
        </tr>
        <tr>
            <td ></td>
            <td colspan="2"><b>LAB GmbH</b></td>
            <td>LAB document number:</td>
            <td colspan="2"><input name="docnrlab" id="docnrlab" type="text" size="30" tabindex="2" /></td>
            <td>Document size:</td>
            <td><select name="docsize_id" id ="docsize_id"><?php echo getDocSizeList(0); ?></select></td>
        </tr>
        <tr>
            <td align="right">Client:</td>
            <td colspan="2"><b>CEH</b></td>
            <td>Client document number:</td>
            <td colspan="2"><input name="docnrclient" id="docnrclient" type="text" size="30" tabindex="2" /></td>
            <td>Current revision:</td>
            <td><select name="revi" id ="revi"><?php echo buildAZSelector(); ?></select></td>
        </tr>
        <tr>
            <td align="right">Title (line 1):</td>
            <td colspan="5"><input name="title1" id="title1" type="text" size="100" tabindex="2" /></td>
            <td>Current doc. phase:</td>
            <td><select name="docphase_id" id ="docphase_id"><?php echo getDocPhaseList(0); ?></select></td>
        </tr>
        <tr>
            <td align="right">Title (line 2):</td>
            <td colspan="5"><input name="title2" id="title2" type="text" size="100" tabindex="2" /></td>
        </tr>
        <tr>
            <td align="right">Title (line 3):</td>
            <td colspan="5"><input name="title3" id="title3" type="text" size="100" tabindex="2" /></td>
        </tr>
        <tr>
            <td align="right">Title (line 4):</td>
            <td colspan="5"><input name="title4" id="title4" type="text" size="100" tabindex="2" /></td>
        </tr>
        <tr>
            <td align="right">File formats:</td>
            <td align="right"><i>editable:</i></td>
            <td ><select name="docformat_editable_id" id ="docformat_editable_id"><?php echo getDocFormatList(0, 1); ?></select></td>
            <td align="right">Filename:</td>
            <td colspan="4" align="left"><input name="file_editable" id="file_editable" type="text" size="50" tabindex="2" /></td>
        </tr>
        <tr>
            <td align="right"></td>
            <td align="right"><i>non-editable:</i></td>
            <td ><select name="docformat_noneditable_id" id ="docformat_noneditable_id"><?php echo getDocFormatList(0, 0); ?></select></td>
            <td align="right">Filename:</td>
            <td colspan="4" align="left"><input name="file_noneditable" id="file_noneditable" type="text" size="50" tabindex="2" /></td>
        </tr>
        <tr>
            <td></td>
            <td colspan="8">
            <div class="button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="submitNewDoc" role="button" aria-disabled="false">
                <span class="ui-button-text">Submit</span>
            </div>
            <div class="button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="cancelNewDoc" role="button" aria-disabled="false">
                <span class="ui-button-text">Cancel</span>
            </div>
            </td>
        </tr>
        </table>
    </form>

提交按钮的 jquery:

    $( "#submitNewDoc" )
        .button()
        .click(function() {
            $( "#documents" ).submit();
        });

当我在 FF 和 IE8 或 IE10 中测试时,数据发布得很好。仅在 IE9 中,数据未发布,我收到“array{}”。

有人知道我做错了什么吗?

** 更新回复穆罕默德的问题 **

除了 MySQL 查询之外,php 文件中没有任何内容:

    // All general includes
    require_once('config.php');
    require_once('functions.general.php');
    require_once('functions.dbase.php');
    //require_once("standardLists.php");

    // make a connection, so we can use mysql_real_escape_string
    $con = mysql_connect($db_host, $db_user, $db_password);
    if (!$con) { die('Could not connect: ' . mysql_error()); }


    // Initialise database object and establish a connection
    // at the same time - db_user / db_password / db_name / db_host
    $db = new ezSQL_mysql($db_user,$db_password,$db_name,$db_host);

    var_dump($_POST); // testing

    /* Storing the info into the DB */

    $sql1 = "INSERT INTO documents 
                    (company_id, docnrsupplier, docnrlab, docnrclient, title1, title2, title3, 
                    title4, docformat_editable_id, docformat_noneditable_id, file_editable, doccat_id, docsize_id, docphase_id, file_noneditable)
                    VALUES (
                            '".$_POST['company_id']."',
                            '".$_POST['docnrsupplier']."', 
                            '".$_POST['docnrlab']."', 
                            '".$_POST['docnrclient']."', 
                            '".$_POST['title1']."', 
                            '".$_POST['title2']."' , 
                            '".$_POST['title3']."',
                            '".$_POST['title4']."', 
                            '".$_POST['docformat_editable_id']."', 
                            '".$_POST['docformat_noneditable_id']."', 
                            '".$_POST['file_editable']."' , 
                            '".$_POST['doccat_id']."' , 
                            '".$_POST['docsize_id']."' , 
                            '".$_POST['docphase_id']."' , 
                            '".$_POST['file_noneditable']."')";

** 更新 2 **

我现在已经尝试了两种类型的按钮,但 IE9 中的结果保持不变:array(0) { } 而 IE8 和 IE10 至少给了我

数组(16) { ["company_id"]=> 字符串(0) ""["docnrsupplier"]=> 字符串(0) ""["doccat_id"]=> 字符串(0) ""["docnrlab "]=> 字符串(0) ""["docsize_id"]=> 字符串(0) ""["docnrclient"]=> 字符串(0) ""["revi"]=> 字符串(1) "A"[“title1”]=> 字符串(0) “” [“docphase_id”]=> 字符串(0) “” [“title2”]=> 字符串(0) “” [“title3”]=> 字符串(0) ""["title4"]=> 字符串(0) ""["docformat_editable_id"]=> 字符串(0) ""["file_editable"]=> 字符串(0) ""["docformat_noneditable_id"]=> 字符串( 0) ""["file_noneditable"]=> 字符串(0) ""} `

    <input class="button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="mySubmit" type="submit" value="Submit" />
    <div class="button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="submitNewDoc" role="button" aria-disabled="false">
        <span class="ui-button-text">Submit</span>
    </div>

我确信我犯了一个错误,我只是找不到它:-( 难道同一个页面有两个表单有问题吗?他们确实有自己的名称和 ID,并且没有双重字段名..

最佳答案

我想我已经找到了它,尽管我对此很不满意: 表单字段嵌套在表格内: <form><table><tr><td><input...>正如你在我原来的问题中看到的。

在进一步搜索后,我读到了有关 jquery Accordion 内表单内表格问题的内容。只是为了尝试,我删除了有关该表的所有 html,所以现在我有类似 <accordion> -> <form> -> <input ....> 的内容。

这有效!因此,出于某种原因,我所做的嵌套一定遇到了 IE9 中的错误。

看起来很糟糕,但确实有效。无论如何,它是供内部使用的,所以它必须这样做。

我希望这可以帮助其他也遇到此问题的人。

关于php - Jquery form.submit 在 IE9 中不发布任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18675324/

相关文章:

javascript - AngularJS 指令部分工作(包括 Plunker 链接)

javascript - 如何使用 jquery $this 从列表中删除特定对象?

javascript - 使用 JQuery/AJAX/PHP 从另一个 URL 抓取并显示 Web 内容

jquery - 问题 : Main confirmation window is shown behind in the dimmed area in jqGrid

asp.net - 如何将客户端 OnClick 操作添加到 ASP.NET 中的文本

javascript - 如何在 jquery 中将值从一个 div 面板转移到另一个?

PHP无效字符错误

php - 在另一个 block 内修改 Twig block

javascript - 从 AJAX 请求更改图像 src

php - 将使用 PHP 创建的 csv 文件导入 Excel 时,如何在数字字符串值中保留前导零?