+ -
当前位置:首页 → 问答吧 → 求助:ajaxForm的提交问题

求助:ajaxForm的提交问题

时间:2009-05-10

来源:互联网

复制代码
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3.   <head>
  4.     <title>ajaxForm Laboratory</title>
  5.     <link rel="stylesheet" type="text/css" href="../../common.css">
  6.     <link rel="stylesheet" type="text/css" href="styles.css">
  7.     <script type="text/javascript"
  8.             src="../../scripts/jquery-1.2.1.js"></script>
  9.     <script type="text/javascript"
  10.             src="../../scripts/support.labs.js"></script>
  11.     <script type="text/javascript" src="../../scripts/jquery.form.js"></script>
  12.     <script type="text/javascript">
  13.       $(function(){
  14.         var options = {
  15.           target: '#responseDisplay',
  16.           beforeSubmit: function(data,set,options) {
  17.             $('#dataDisplay').html($.toSource(data));
  18.             var disposition = $('#dispositionGroup input:radio').fieldValue()[0];
  19.             if (disposition != '') options[disposition] = true;
  20.             var optionsClone = $.extend({},options);
  21.             optionsClone.beforeSubmit = undefined;
  22.             $('#optionsDisplay').html($.toSource($.extend({},optionsClone),true));
  23.             return true;
  24.           }
  25.         };
  26.         $('#testForm').ajaxForm(options);
  27.    [backcolor=#FF0000]     $('#testForm').bind('form.pre.serialize',function(type,$form,options,veto) {
  28.           if ($('#semanticControl').fieldValue().length != 0) options.semantic = true;[/backcolor]
  29.         });
  30.       });
  31.     </script>
  32.     <style>
  33.       #console div {
  34.         overflow: inherit;
  35.       }
  36.       #console div div {
  37.         width: 540px;
  38.         overflow: auto;
  39.       }
  40.     </style>
  41.   </head>
  42.   <body>
  43.     <h1>ajaxForm Laboratory</h1>
  44.     <fieldset>
  45.       <legend>The form</legend>
  46.       <div>
  47.         <form id="testForm" action="reflectData.jsp" method="post">
  48.           <div>
  49.             <label>Text field:</label>
  50.             <input type="text" name="text" value="some text"/>
  51.           </div>
  52.           <div>
  53.             <label>Dropdown:</label>
  54.             <select name="dropdown">
  55.               <option value="dropdown 1">One</option>
  56.               <option value="dropdown 2">Two</option>
  57.               <option value="dropdown 3" selected="selected">Three</option>
  58.               <option value="dropdown 4">Four</option>
  59.               <option value="dropdown 5">Five</option>
  60.             </select>
  61.           </div>
  62.           <div>
  63.             <label>Input image:</label>
  64.             <input type="image" name="inputImage" src="image.1.jpg" value="hibiscus blossom"/>
  65.           </div>
  66.           <div>
  67.             <label>Check box group:</label>
  68.             <input type="checkbox" name="cb" value="checkbox 1">One
  69.             <input type="checkbox" name="cb" value="checkbox 2" checked="checked">Two
  70.             <input type="checkbox" name="cb" value="checkbox 3">Three
  71.           </div>
  72.           <div>
  73.             <label>Radio group:</label>
  74.             <input type="radio" name="radio" value="radio 1">One
  75.             <input type="radio" name="radio" value="radio 2" checked="checked">Two
  76.             <input type="radio" name="radio" value="radio 3">Three
  77.           </div>
  78.           <div>
  79.             <label>Text area:</label>
  80.             <textarea name="textarea" rows="2">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</textarea>
  81.           </div>
  82.           <div>
  83.             <label> </label>
  84.             <input type="submit" name="submitButton" value="Submit me!"/>
  85.           </div>
  86.         </form>
  87.       </div>
  88.     </fieldset>
  89.     <fieldset>
  90.       <legend>Control Panel</legend>
  91.       <div>
  92.         <form action="" onsubmit="return false;">
  93.           <div>
  94.             <label>Semantic order:</label>
  95.             <input type="checkbox" name="semantic" id="semanticControl"/> Check for yes
  96.           </div>
  97.           <div id="dispositionGroup">
  98.             <label>After submission:</label>
  99.             <input type="radio" name="disposition" value="" checked="checked"/> Leave form be
  100.             <input type="radio" name="disposition" value="resetForm"/> Reset form
  101.             <input type="radio" name="disposition" value="clearForm"/> Clear form
  102.           </div>
  103.         </form>
  104.       </div>
  105.     </fieldset>
  106.     <fieldset>
  107.       <legend>Results</legend>
  108.       <div id="console">
  109.         <div>
  110.           <label>Submitted data:</label>
  111.           <div id="dataDisplay"></div>
  112.         </div>
  113.         <div>
  114.           <label>Options:</label>
  115.           <div id="optionsDisplay"></div>
  116.         </div>
  117.         <div>
  118.           <label>Response:</label>
  119.           <div id="responseDisplay"></div>
  120.         </div>
  121.       </div>
  122.     </fieldset>
  123.   </body>
  124. </html>

请问红色的绑定事件是什么意思
图片:
'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" title="Click Here To EnLarge">
# $('#testForm').bind('form.pre.serialize',function(type,$form,options,veto) {
#           if ($('#semanticControl').fieldValue().length != 0) options.semantic = true;就这个事件

作者: lansex   发布时间: 2009-05-10

相关阅读 更多