使用 jQuery 或 Javascript 提交表单**并刷新页面**

发布于 2025-01-07 04:16:57 字数 1287 浏览 3 评论 0原文

以下代码更改网格控件的配置,但此重新配置仅在页面刷新发生后发生。

如何自动让用户单击提交按钮? 我看到的所有 jQuery 示例都涉及 AJAX,但由于我处于需要刷新页面的独特情况,似乎没有人有示例可用的

<% using (Html.Configurator("The grid should...")
              .PostTo("Details", "TLSWorkflow")
              .Begin())
   { %>
    <ul>
        <li><%= Html.CheckBox("grouping", false, "allow <strong>grouping</strong> of data")%></li>
        <li><%= Html.CheckBox("filtering", false, "allow <strong>filtering</strong> of data")%></li>
        <li><%= Html.CheckBox("paging", false, "have <strong>pages</strong> with 10 items")%></li>
        <li><%= Html.CheckBox("ajax", true, "make <strong>AJAX</strong> requests")%></li>
        <li><%= Html.CheckBox("scrolling", true, "show a  <strong>scrollbar</strong> when there are many items")%></li>
        <li><%= Html.CheckBox("sorting", true, "allow <trong>sorting</strong> of data")%></li>
        <li><%= Html.CheckBox("showFooter", false, "show footer")%></li>
    </ul>
    <button class="t-button" type="submit">Apply</button>
<% } %>

The following code changes the configuration of a Grid control, but this reconfiguration only happens after a page refresh occurs.

How can I automate the user clicking the submit button? All the jQuery samples I see involve AJAX, but since I'm in the unique situation of needing to refresh the page, no one seems to have a sample available

<% using (Html.Configurator("The grid should...")
              .PostTo("Details", "TLSWorkflow")
              .Begin())
   { %>
    <ul>
        <li><%= Html.CheckBox("grouping", false, "allow <strong>grouping</strong> of data")%></li>
        <li><%= Html.CheckBox("filtering", false, "allow <strong>filtering</strong> of data")%></li>
        <li><%= Html.CheckBox("paging", false, "have <strong>pages</strong> with 10 items")%></li>
        <li><%= Html.CheckBox("ajax", true, "make <strong>AJAX</strong> requests")%></li>
        <li><%= Html.CheckBox("scrolling", true, "show a  <strong>scrollbar</strong> when there are many items")%></li>
        <li><%= Html.CheckBox("sorting", true, "allow <trong>sorting</strong> of data")%></li>
        <li><%= Html.CheckBox("showFooter", false, "show footer")%></li>
    </ul>
    <button class="t-button" type="submit">Apply</button>
<% } %>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

满天都是小星星 2025-01-14 04:16:57
$("selector for your form here").submit();

// OR

$("button.t-button").click();

(顺便说一句,你在这里的情况并不独特。)

$("selector for your form here").submit();

// OR

$("button.t-button").click();

(By the way, you're hardly in a unique situation here.)

缱绻入梦 2025-01-14 04:16:57

只需为您的表单提供一个 ID 并对其调用 submit 即可:

<form id="myform">...</form>

使用纯 JavaScript:

document.getElementById('myform').submit();

或使用 jQuery:

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

Just give your form an ID and call submit on it:

<form id="myform">...</form>

In plain JavaScript:

document.getElementById('myform').submit();

or using jQuery:

$('#myform').submit();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文