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

.ajaxform 在驗證 submitHandler 中不起作用?

.ajaxform not working inside the validation submitHandler?(.ajaxform 在驗證 submitHandler 中不起作用?)
本文介紹了.ajaxform 在驗證 submitHandler 中不起作用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我使用 jquery 驗證插件在提交前驗證表單在 submitHandler 我使用 ajax 請求用 ajax 發布表單在我使用 .ajax 發送請求之前,但現在表單有圖像并且很難通過正常的ajax請求序列化文件元素,因此我使用了這個插件http://www.malsup.com/jquery/form/

i use the jquery validation plugin to validate form before submit in submitHandler i use ajax request to post the form with ajax before i used .ajax to send the request but now the form have image and its so hard to serialize the file element through the normal ajax request and because of this i used this plugin http://www.malsup.com/jquery/form/

現在使用插件后,ajax 請求無法正常工作,不知道為什么這是第一個使用普通 ajax 調用的示例

now after using the plugin the ajax request not working at it all don't know why this the first example with the normal ajax call

$(document).ready(function(){
    $("#categoryForm").validate({
    submitHandler: function() {
            $.ajax({
                type:'POST', 
                url: 'actions/add-category.php', 
                data: $("#categoryForm").serialize(), 
                success: function(response) {
                     $('#status').html(response);
                    }
                });

        return false;
    }
    });
});

使用插件后的這個

$(document).ready(function(){
        $("#categoryForm").validate({
        submitHandler: function() {
                $('#categoryForm').ajaxForm(function() {
                alert('the form was successfully processed');
            });

            return false;
        }
        });
    });

第二個不工作

推薦答案

嘗試反轉函數:

jQuery('#form_id').ajaxForm({
    beforeSubmit: function() {
        jQuery("#form_id").validate({
            rules: {
                first_name: "required",
                last_name: "required"
            },
            messages: {
                first_name: "Required",
                last_name: "Required"
            }
        });
        return jQuery('#form_id').valid();
    },
    success: function(resp) {
        jQuery('#resp').html(resp).fadeIn('fast');
    }
});

其中 #resp 是將接收從您的 #form_id 發布的文件生成的 HTML 的 ID

Where #resp is the ID that will receive the HTML generated from the file your #form_id posted

這篇關于.ajaxform 在驗證 submitHandler 中不起作用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

jQuery/JavaScript Library for avatar creation?(用于創建頭像的 jQuery/JavaScript 庫?)
How to do following mask input problem?(如何做以下掩碼輸入問題?)
Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設置值/標簽的問題)
how to unit-test private methods in jquery plugins?(如何對 jquery 插件中的私有方法進行單元測試?)
stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動網站配置偏移量/對齊元素?)
jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽輸入插件.當文本框獲得焦點時選擇所有內容)
主站蜘蛛池模板: 精品啪啪 | 久久男人天堂 | 精品国产一区久久 | 久久视频免费看 | 精精国产xxxx视频在线野外 | 午夜精品一区二区三区免费视频 | 午夜丰满少妇一级毛片 | 日韩在线免费播放 | 91麻豆精品国产91久久久更新资源速度超快 | 亚洲精品在线免费 | a级片网站 | 欧美国产91 | 免费在线观看黄视频 | 亚洲成av人片在线观看无码 | 一级毛片免费 | 91精品国产91久久久 | 中文字幕在线精品 | 国产精品成人在线播放 | 亚洲二区在线观看 | 国产精品久久久久久婷婷天堂 | 精品视频在线播放 | 亚洲高清一区二区三区 | 国产精品国产成人国产三级 | 国产高清在线 | 曰韩一二三区 | 亚洲高清视频在线观看 | 亚洲高清免费视频 | 国产一级毛片精品完整视频版 | 婷婷一级片 | 一区中文字幕 | 精品国产乱码久久久久久丨区2区 | 日韩视频在线观看中文字幕 | 精品国产乱码久久久久久蜜柚 | 香蕉久久久 | 在线免费观看黄色av | 国产污视频在线 | 91精品一区 | 久久国产视频网站 | 男女黄网站| 国产美女在线精品免费 | 99精品国产一区二区三区 |