Chrome / safari (webkit?) Doesn't post values ​​when submitted via Javascript.submit ()

I am submitting some of my forms using javascript / jquery.

$("#myform").submit();

this works fine in Firefox, but none of my form values ​​are hosted in Safari or Chrome.

When I check the $ _POST variable, it populates correctly in Firefox, but on safari / chrome the values ​​of $ _POST are empty.

I post this when the OK dialog buttong gets a click (works fine in FF)

$("form#form_add_file_to_theme").submit();

this is my form (the surrounding div becomes the .jQuery UI dialog box)

<div id="modal_create_themefile" style="display:none;">         
    <form action="" id="form_add_file_to_theme" name="form_add_file_to_theme" method="post">            
        <div class="field">
            <label for="var_template_name">File name</label>
            <input type="text" class="text" id="var_template_name" name="var_template_name" />
        </div>

        <div class="field">
            <label for="var_template_type">File type</label>
            <select id="var_template_type" name="var_template_type">
                <option value="css">CSS</option>
                <option value="include">Partial</option>
                <option value="js">Javascript</option>
            </select>
        </div>
    </form>                
</div>

printing $ _POST in php gives:

Array ( [var_template_name] => [var_template_type] => css )

so the select box is sent, not text boxes ...

UPDATE: value = "test", , . ( ) , webkit. Chrome Safari "" "" .

+3
4

. .

jQuery UI - , webkit . Webkit .

, :

dialog.data("dialog").uiDialog.find("form").submit();

, , .

+2

POST, , "var_template_name", , , .

, - .

Javascript, ? , , - :

if (document.getElementById('var_template_name').value = '')

:

if (document.getElementById('var_template_name').value == '')
+2

. , submit , . , , -.

- ajax submit.

.

$ (. "/Submit_url", $( "# form_id" ) ());

, , .

0

. , . html . "--". . Jorre, Chrome, , , . div div -edit-dialog. . . , html, jquery.ui.

<div style="display: none; z-index: 1000; outline-width: 0px; outline-style: initial; outline-color: initial; position: absolute; " class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
  <div id="interest-edit-dialog" title="whatever" class="ui-dialog-content ui-widget-content">
    <form id="interestDialogForm" name="interestDialogForm" action="einterest" method="post" enctype="multipart/form-data">
    <p class="validateTips"></p>
  <fieldset>
    <?php echo $interest_list; ?>
    <p><input type="text" id="myinterest1" class="myinterest1" name="myinterest1" value="FOO" /></p>
    <p><input type="text" id="myinterest2" class="myinterest2" name="myinterest2" value="BAR" /></p>
    <p><input type="text" id="myinterest3" class="myinterest3" name="myinterest3" value="" /></p>
    <p><input type="text" id="myinterest4" class="myinterest4" name="myinterest4" value="" /></p>
    <p><input type="text" id="myinterest5" class="myinterest5" name="myinterest5" value="" /></p>
    <input type="hidden" name="serial" id="serial" value="" />
  </fieldset>
    </form>
  </div>
  <div class="ui-dialog-buttonpane ui-helper-clearfix">
  </div>
</div>

javascript

 $("#interestDialogForm").submit();
0

Source: https://habr.com/ru/post/1751194/


All Articles