zoukankan      html  css  js  c++  java
  • JQuery Ajax 捕获异常

    function deleterepair(repairid) {
    	var id = $('#repair_id').val();
    	$.ajax( {
    		url : 'RepairAction!delRepair.action?repairid=' + id,
    		type : 'post',
    		dataType : 'json',
    		success : function(data, textStatus, jqXHR) {
    			if(data=='...'){         //对服务器端返回的数据进行判断;前提是在action中设置好返回参数;
                                alert('......');//处理方法;
                            }else{    
    
                                alert('......');//处理方法;
    
                            }
    				
    		}
    
    	});
    
    }


    另一种方法:

    function deleterepair(repairid) {
    	var id = $('#repair_id').val();
    	$.ajax( {
    		url : 'RepairAction!delRepair.action?repairid=' + id,
    		type : 'post',
    		dataType : 'json',
    		success : function(data, textStatus, jqXHR) {
    
                                alert('......');//处理方法;
    		
    		}
                    error:function(XmlHttpRequest,textStatus, errorThrown)
                    {
                         alert('删除失败'+XmlHttpRequest.responseText);
                    }
          });   
     }
    
    

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    centos 7 install
    sbt
    maven create project
    java异常个人理解
    (poj1094)Sorting It All Out
    stars
    Following Orders(拓扑排序)
    The House Of Santa Claus(dfs)
    Prime Path(bfs)
    Fence Repair(优先队列容器的应用)
  • 原文地址:https://www.cnblogs.com/dqsweet/p/4927810.html
Copyright © 2011-2022 走看看