Trigger Jquery Event after an onsubmit

2019-08-27 02:46发布

问题:

I would like to trigger a Div to open after a form completes an action. But I need to it only happen based on one particular action so it is specific. I'm not sure where to start.

回答1:

Ok, so if a new page is not loaded after your form completes an action (i.e. you have submitted it), I would assume you mean you're not redirecting the user to a different page; you're just posting back the current "Cart" page with the updated data.

So your question is, "How do I display content on my page only following a postback".

While jQuery does all things, it's probably not needed here (if I've interpreted your problem correctly, at least).

You just need to check whether the page is being loaded for the first time or is being loaded in response to a postback. For that you use the Page.IsPostBack property:

<% if (Page.IsPostBack) { %>
   <div id="myMessage"><p>You added something to your cart.</p></div>
<% } %>

If this isn't what you meant, you need to explain your question a bit more.