以jquery形式捕获submit事件 [英] catching the submit event in a jquery form

查看:82
本文介绍了以jquery形式捕获submit事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net页面上,我使用了http://www.thecodemine.org上的jQuery Form向导,现在我(几乎)已正确配置了所有内容,但我遇到的问题是不知道如何处理提交事件.

我是jQuery/AJAX的新手,而上次在asp.net页面上工作的工作是几年前的事情.

这是在页面中定义表单参数的脚本标记:

On an asp.net page, I used the jQuery Form wizard from http://www.thecodemine.org, and now that I have (almost) everything configured properly, I''m having the problem of not knowing how to handle the submit event.

I''m new to jQuery/AJAX and the last time work had me working on asp.net pages was a few years back.

Here''s the script tag defining the form parameters in the page:

<script type="text/javascript" language="javascript">
$(function() {
   $("#RegistrationFormEn").formwizard({ //wizard settings 
       formPluginEnabled: true, //Ajax is used to post the form to the server
       validationEnabled: true, //The Validation plugin is used for validating the form at each step
       focusFirstInput: true // puts focus at the first input on each step
    },
    {
       //validation settings
       messages: { email: "Invalid email (custom message)"} // custom message shown when the email is invalid
    },
    {
      // form plugin settings
     success: function(data) { // called when the form has been submitted correctly to the server
         $("#status").fadeTo(500, 1, function() { $(this).html("You are now registered!").fadeTo(5000, 0); })
    },
    /*beforeSubmit: function(data) { // called just before the form is submitted
         alert('data being sent to the server' + data.hotelOption);
    },*/
    dataType: 'json',
    resetForm: true,
    textSubmit: 'Register'
  }
);
});
</script> 


以及我的js文件中的代码:


and the code in my js file:

$(document).ready(function() {
//show the attach visa
$("#VisaHelpNeeded").click(function() {
    $("#VisaAttach").fadeIn()
});
//hide the attach visa
$("#VisaHelpNotNeeded").click(function() {
    $("#VisaAttach").fadeOut()
});
//show the help in getting visa
$("#VisaIsRequired").click(function() {
    $("#VisaJorEmbassy").fadeIn()
});
//hide the help in getting visa
$("#VisaIsNotRequired").click(function() {
    $("#VisaJorEmbassy").fadeOut()
});

$().ajaxStart(function() {
    // 'this' is the document object
    alert(this === document);
    alert('caught the ajax!');
});

$().ajaxForm(function() {
    processJson(this.data);
});

$().submit.click(function() {
   alert('caught the submit');
});
});


您可以看到最后几种方法只是陷阱,以查看触发了哪种方法.我很困惑地看到他们显然没有抓住提交者.

现在有一个问题是如何处理Submit事件?因为下一步是尝试将数据发送到Web服务,然后将所有数据通过管道传输到DB并发送电子邮件(Web服务没有问题,它捕获了提交内容,这给我带来了麻烦).

非常感谢所有帮助,因此,非常感谢您.


You can see that the last few methods were just traps to see which method gets fired. I''m baffled to see that none of them apparently caught the submit.

Now one question is how to handle the submit event? Because the next step is to try and have the data sent to a webservice that would then pipe everything into a DB and send an email (I have no problem with the webservice, its catching the submit that''s giving me a hassle).

All help is very much appreciated, so a very big thank you in advance.

推荐答案

(功能( ){


(" ).formwizard( {// 向导设置 formPluginEnabled: true // Ajax用于发布表单发送到服务器 validationEnabled: true // Validation插件用于在每个步骤中验证表单 focusFirstInput: true // 将焦点放在第一个输入上每一步 }, { // 验证设置 消息:{电子邮件:" } 电子邮件无效时显示的自定义消息 }, { // 表单插件设置 成功:函数(数据){// 表单已正确提交到服务器
("#RegistrationFormEn").formwizard({ //wizard settings formPluginEnabled: true, //Ajax is used to post the form to the server validationEnabled: true, //The Validation plugin is used for validating the form at each step focusFirstInput: true // puts focus at the first input on each step }, { //validation settings messages: { email: "Invalid email (custom message)"} // custom message shown when the email is invalid }, { // form plugin settings success: function(data) { // called when the form has been submitted correctly to the server


(" ).fadeTo( 500 1
("#status").fadeTo(500, 1, function() {


这篇关于以jquery形式捕获submit事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆