表单提交后刷新Jquery移动页面

时间:2011-11-21 17:40:34

标签: php javascript jquery mysql mobile

我正在尝试在提交表单后进行页面刷新。该页面当前显示基于特定查询的sql行列表。表单会更改列的状态,因此某些项目可能不再符合要显示的条件。

目前,我有以下表格:

<form action="<?=$_SERVER['PHP_SELF']; ?>" method="post">
<input type=hidden name="potential" value="<?=$assignment['potentialid'];?>"
<fieldset>
    <div data-role="fieldcontain">

        <div class="ui-grid-b">
            <div class="ui-block-a">
                <label for="user_name" class="user_name">User:</label>
            </div>
            <div class="ui-block-b">
                <select name="user_name"><?php  users($name);?></select><br> 
            </div>
        </div> <!-- /close grid -->
        <div class="ui-grid-b">
            <div class="ui-block-a">
                <label for="quadrant" class="quadrant">Change Quadrant:</label>
            </div>
            <div class="ui-block-b">                                
                <select name="quadrant">
                    <option value="<?=$assignment['cf_648']?>" selected><?=$assignment['cf_648']?></option>
                    <option value="1-1 Create">1-1 Create</option>
                    <option value="1-2 Shape">1-2 Shape</option>
                    <option value="1-3 Assess">1-3 Assess</option>
                    <option value="1-4 Formalize">1-4 Formalize</option>
                    <option value="2-1 Determine">2-1 Determine</option>
                    <option value="2-2 Act">2-2 Act</option>
                    <option value="2-3 Serve">2-3 Serve</option>
                    <option value="2-4 Store">2-4 Store</option>
                    <option value="3-1 Feel">3-1 Feel</option>
                    <option value="3-2 Experience">3-2 Experience</option>
                    <option value="3-3 Share">3-3 Share</option>
                    <option value="3-4 Impress">3-4 Impress</option>
                    <option value="4-1 Understand">4-1 Understand</option>
                    <option value="4-2 Prioritize">4-2 Prioritize</option>
                    <option value="4-3 Complete">4-3 Complete</option>
                    <option value="4-4 Communicate">4-4 Communicate</option>
                </select>
            </div>
        </div>
    </div>
    <input type="submit" data-theme="a" name="submit" value="Submit" onClick="window.location.reload(true)" rel="external"></input>
</fieldset>

当提交此表单时,我收到jquery mobile“错误加载页面”,并且让我实际看到在提交表单后我需要点击f5的更改。查询是正确的,并且在数据库中生效。

有关刷新此页面的最佳方法以及在表单提交后显示的列表视图的任何建议吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

问题在于您应该使用js代码处理表单提交

<script type="text/javascript">
      function formSubmit() {
          //here you can do whatever you want
      }
</script>
<form method="post" action="javascript:formSubmit();">
    <input type="submit" data-theme="a" name="submit" />
</form>