久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  1. <tfoot id='x8SmG'></tfoot>
  2. <legend id='x8SmG'><style id='x8SmG'><dir id='x8SmG'><q id='x8SmG'></q></dir></style></legend>

  3. <i id='x8SmG'><tr id='x8SmG'><dt id='x8SmG'><q id='x8SmG'><span id='x8SmG'><b id='x8SmG'><form id='x8SmG'><ins id='x8SmG'></ins><ul id='x8SmG'></ul><sub id='x8SmG'></sub></form><legend id='x8SmG'></legend><bdo id='x8SmG'><pre id='x8SmG'><center id='x8SmG'></center></pre></bdo></b><th id='x8SmG'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='x8SmG'><tfoot id='x8SmG'></tfoot><dl id='x8SmG'><fieldset id='x8SmG'></fieldset></dl></div>

        <bdo id='x8SmG'></bdo><ul id='x8SmG'></ul>
    1. <small id='x8SmG'></small><noframes id='x8SmG'>

      struts2 jquery ajax 和客戶端驗證不能一起工作

      struts2 jquery ajax and client side validatio not working toghether(struts2 jquery ajax 和客戶端驗證不能一起工作)

        <i id='Sji8h'><tr id='Sji8h'><dt id='Sji8h'><q id='Sji8h'><span id='Sji8h'><b id='Sji8h'><form id='Sji8h'><ins id='Sji8h'></ins><ul id='Sji8h'></ul><sub id='Sji8h'></sub></form><legend id='Sji8h'></legend><bdo id='Sji8h'><pre id='Sji8h'><center id='Sji8h'></center></pre></bdo></b><th id='Sji8h'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Sji8h'><tfoot id='Sji8h'></tfoot><dl id='Sji8h'><fieldset id='Sji8h'></fieldset></dl></div>
        • <bdo id='Sji8h'></bdo><ul id='Sji8h'></ul>

          <tfoot id='Sji8h'></tfoot>

                <tbody id='Sji8h'></tbody>
              <legend id='Sji8h'><style id='Sji8h'><dir id='Sji8h'><q id='Sji8h'></q></dir></style></legend>

              • <small id='Sji8h'></small><noframes id='Sji8h'>

                本文介紹了struts2 jquery ajax 和客戶端驗證不能一起工作的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我使用了來自 http://struts.jgeppert.com 的標準代碼片段/struts2-jquery-showcase/index.action 和 http://code.google.com/p/struts2-jquery/wiki/Validation.

                I have used standard code snippet from http://struts.jgeppert.com/struts2-jquery-showcase/index.action and http://code.google.com/p/struts2-jquery/wiki/Validation.

                但是客戶端和 ajax 服務(wù)器端驗證不能一起工作.

                But the client side and ajax server side validations are not working together.

                問題是表單提交不會停止并且即使我們 preventDefault 或執(zhí)行其他任何操作也會調(diào)用操作.

                The problem is form submission does not stop and action gets called even if we preventDefault or do anything else.

                <%@ taglib prefix="s" uri="/struts-tags"%>
                <%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
                <html>
                  <head>
                    <sj:head jqueryui="true"/>
                
                  </head>
                  <body>
                        <div id="result">
                            <s:actionerror/>
                            <s:fielderror fieldName="name" value="eroor"></s:fielderror>
                        Submit form bellow.</div>
                
                        <!-- A List for Global Error Messages -->
                    <ul id="formerrors" class="errorMessage"></ul>
                
                    <s:form id="formValidateCustom" action="register1.action" namespace="/" theme="simple" cssClass="yform" >
                        <fieldset>
                            <legend>AJAX Form with Validation</legend>
                                <div class="type-text">
                                    <label for="echo">User: <span id="loginuserError"></span></label>
                                                <sj:textfield id="name" name="name" />
                                </div>
                                <div class="type-text">
                                    <label for="echo">Password: <span id="loginpasswordError"></span></label>
                                        <sj:textfield id="password" name="password" />
                                </div>
                                <div class="type-button">
                                        <sj:submit 
                                                targets="result" 
                                                button="true" 
                                                validate="true" 
                                                validateFunction="customeValidation"
                                                value="Submit" 
                                                onBeforeTopics="before"
                                                timeout="2500" 
                                                indicator="indicator"
                                        />
                                </div>
                        </fieldset>
                    </s:form>
                        <script type="text/javascript">
                
                        function customeValidation(form, errors) {
                
                                //List for errors
                //              alert("in js");
                                var list = $('#formerrors');
                
                                //Handle non field errors 
                                if (errors.errors) {
                                        $.each(errors.errors, function(index, value) { 
                                                list.append('<li>'+value+'</li>
                ');
                                        });
                                }
                
                                //Handle field errors 
                                if (errors.fieldErrors) {
                                        $.each(errors.fieldErrors, function(index, value) { 
                                                var elem = $('#'+index);
                                                if(elem)
                                                {
                                                        alert(value[0]);
                                                }
                                        });
                                }
                        }
                        $.subscribe('before', function(event,data) {
                             var fData = event.originalEvent.formData;
                             alert('About to submit: 
                
                ' + fData[0].value + ' to target '+event.originalEvent.options.target+' with timeout '+event.originalEvent.options.timeout );
                             var form = event.originalEvent.form[0]; 
                             if (form.name.value.length  < 2) { 
                                 alert('Please enter a value with min 2 characters');
                
                                 **// the event does not stop here if we use ajax validation i.e validate = true, if we remove it then this works.**
                                 event.originalEvent.options.submit = false; 
                             } 
                            });
                    </script>
                  </body>
                </html>
                

                如果我們使用 ajax 驗證,即在提交按鈕中使用 validate = true,則 event.originalEvenet.options.submit = false 不會在此處停止,如果我們將其刪除,則此方法有效.**

                the event.originalEvenet.options.submit = false does not stop here if we use ajax validation i.e validate = true in submit button, if we remove it then this works.**

                推薦答案

                嗯,

                我在這里查看了 struts2 jquery 插件代碼 o.validate 調(diào)用 struts2 中的驗證函數(shù),而 o.options.submit 設(shè)置為 false 時不會調(diào)用實際操作.

                I looked into struts2 jquery plugin code here o.validate calls validate function in struts2 while o.options.submit when set to false does not calls the actual action.

                現(xiàn)在,如果我的客戶端驗證也應(yīng)該能夠阻止 ajax 驗證.

                Now if my client side validation is should be able to block ajax validation too.

                但在這里,我無法設(shè)置 event.originalEvent.validate = false 因此 ajax 驗證將始終發(fā)生.

                But here, I am not able to set event.originalEvent.validate = false hence ajax validation will happen always.

                需要某種方式來解決這個問題,這是一個原生庫,有一個用例,其中客戶端驗證必須能夠撤銷服務(wù)器端驗證并避免網(wǎng)絡(luò)調(diào)用.

                Need someway to fix this is native library to have a use case, where client side validation must be able to revoke server side validation and avoid network call.

                params.beforeSubmit = function(formData, form, formoptions) {
                
                        var orginal = {};
                        orginal.formData = formData;
                        orginal.form = form;
                        orginal.options = formoptions;
                        orginal.options.submit = true;
                
                        s2j.publishTopic(elem, always, orginal);
                
                        if (o.onbef) {
                            $.each(o.onbef.split(','), function(i, topic) {
                                elem.publish(topic, elem, orginal);
                            });
                        }
                
                        if (o.validate) {
                            orginal.options.submit = s2j.validateForm(form, o);
                            orginal.formvalidate = orginal.options.submit; 
                            if (o.onaftervalidation) {
                                $.each(o.onaftervalidation.split(','), function(i, topic) { 
                                    elem.publish(topic, elem, orginal);
                                });
                            }  
                        }
                        if (orginal.options.submit) {
                            s2j.showIndicator(indi);
                            if(!o.datatype || o.datatype !== "json") {
                                if (o.loadingtext && o.loadingtext !== "false") {
                                    $.each(o.targets.split(','), function(i, target) {
                                        $(s2j.escId(target)).html(o.loadingtext);
                                    });
                                }
                                else if (s2j.defaults.loadingText !== null) {
                                    $.each(o.targets.split(','), function(i, target) {
                                        $(s2j.escId(target)).html(s2j.defaults.loadingText);
                                    });
                                }
                            }
                        }
                        return orginal.options.submit;
                    };
                
                    params.success = s2j.pubSuc(elem, always, o.onsuc, indi, 'form', o);
                    params.complete = s2j.pubCom(elem, always, o.oncom, o.targets, indi, o);
                    params.error = s2j.pubErr(elem, always, o.onerr, o.errortext, 'html');
                
                    $.each(o.formids.split(','), function(i, fid) {
                        s2j.log('submit form : ' + fid);
                        $(s2j.escId(fid)).ajaxSubmit(params);
                    });
                
                    return false;
                });
                

                這篇關(guān)于struts2 jquery ajax 和客戶端驗證不能一起工作的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調(diào)用完成)
                JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
                1. <tfoot id='KDjEO'></tfoot>
                          <tbody id='KDjEO'></tbody>

                        <small id='KDjEO'></small><noframes id='KDjEO'>

                        <i id='KDjEO'><tr id='KDjEO'><dt id='KDjEO'><q id='KDjEO'><span id='KDjEO'><b id='KDjEO'><form id='KDjEO'><ins id='KDjEO'></ins><ul id='KDjEO'></ul><sub id='KDjEO'></sub></form><legend id='KDjEO'></legend><bdo id='KDjEO'><pre id='KDjEO'><center id='KDjEO'></center></pre></bdo></b><th id='KDjEO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='KDjEO'><tfoot id='KDjEO'></tfoot><dl id='KDjEO'><fieldset id='KDjEO'></fieldset></dl></div>
                      1. <legend id='KDjEO'><style id='KDjEO'><dir id='KDjEO'><q id='KDjEO'></q></dir></style></legend>
                        • <bdo id='KDjEO'></bdo><ul id='KDjEO'></ul>

                          主站蜘蛛池模板: 日本成人在线观看网站 | 久久亚洲二区 | 91麻豆蜜桃一区二区三区 | 亚洲精品丝袜日韩 | 亚洲色图综合 | 久久精品视频一区二区三区 | 亚洲综合无码一区二区 | 精品久久久久久久 | 亚洲成人免费网址 | 久久综合影院 | 亚洲第一在线 | 成人在线播放网址 | 亚洲永久 | 麻豆国产一区二区三区四区 | 国产99久久精品一区二区永久免费 | 99热精品在线观看 | 亚洲精品久久久久久久久久久久久 | 亚洲精品久久久久avwww潮水 | 精品国产乱码久久久久久丨区2区 | 日韩精彩视频 | 99久久精品国产麻豆演员表 | 九九九视频在线 | 亚洲97 | 日韩中文字幕2019 | 久久久夜色精品亚洲 | 日韩一区二区三区av | 黄免费观看 | 日韩精品中文字幕一区二区三区 | 精品久久久久久久 | 狠狠ri | 蜜臀91视频| 草久久 | 日本偷偷操 | 国产精品精品久久久 | 久久久国产一区二区三区 | 性国产xxxx乳高跟 | 久久视频精品 | 久久男人 | 国产高清在线观看 | 日韩久久精品视频 | 日韩欧美大片在线观看 |