When jQuery submits the form, the browser intercepts by default

Let’s make a feature today. When the user clicks on the query, first verify whether the user’s query times are sufficient. If enough, use the form to submit and jump to the new interface. Why use the form? Because the data is sensitive, it is not suitable for the browser address The above is displayed to prevent users from modifying at will and causing data problems.
When axaj sends a request -> verify that the number of user queries is enough, and if enough, submit the form in the ajax method. Firefox and Google browsers directly intercept the single-out window by default. IE does not intercept it because the browser will treat this as not a user The click event directly jumps to the connection as an ad interception, (triggering the click event first makes an ajax request, and then re-links to jump in ajax, which does not belong to the user's direct event jump), so we need to jump to the interface after the axaj request.
Will be intercepted to write:

$("#seach").click(function(){
    
    
$.post(contextPath+"/areaLabitem/validateCount.do",param,function(data){
    
    
            if(data.statu == "error"){
                jAlert(data.result, function(r) {
    
    
                    return;
                });
            }else{
                $("#areaLabitemForm").submit();    //放在ajax里面          
            }
    $("#areaLabitemForm").submit();
});

Will not be intercepted
special attention, ajax need to change the synchronization request, otherwise there will be problems. :

$("#seach").click(function(){
    
    
    $.ajax({ 

        type: "post", 

        url: contextPath+"/areaLabitem/validateCount.do", 

        cache:false, 

        async:false, //改成同步请求

        dataType: 'json', 

        data:param,

        success: function(d){
    
     

            if(d.statu == "error"){
                jAlert(d.result, function(r) {
    
    
                    return;
                });
                return;
            }else{
                flag = true;
            }

        } });
    if(flag == true){
        $("#areaDetail").submit();
    }
    }

Guess you like

Origin blog.csdn.net/Qin_HongKun/article/details/80899006