2013-12-19 2 views
1

두 개의 경고를 생성했습니다. 성공적인 AddStaff에 성공 경고가 나타나야합니다. 직원이 추가 할 수 없으면 경고 경고가 나타나야합니다. 이것은 내가 무엇을했는지 있습니다 : 직원을 추가 할 때ajax 레코드가 추가되면 경고를 표시합니다.

<div class="alert alert-success" style="display: none" id="AddLateStudentAlert"><div class="alert alert-warnning" style="display: none" id="WarningAlert"> 

이 직원

function AddStaff(Staff) { 
     ajReq.abort(); 
     ajReq = $.ajax({ 
      type: "POST", 
      url: "Services/Staff.asmx/Staff", 
      data: "{'Staff':'" + Staff+ "'}", 
      contentType: "application/json; charset=utf-8", 
      dataType: "json", 

      success: function (msg) { 

       $('#SucessAlert').show(); 
       $("#AddLateStudentAlert").fadeOut(5000); 

      },else:(!sucess) { 
       $('#WarningAlert').show(); 
    } 

경고 용량이 작동하지 추가 내 아약스는, 항상 경고가 표시됩니다. 아무도 왜 내게 말할 수 있습니까?

답변

0
function AddStaff(Staff) { 
    ajReq.abort(); 
    ajReq = $.ajax({ 
     type: "POST", 
     url: "Services/Staff.asmx/Staff", 
     data: "{'Staff':'" + Staff+ "'}", 
     contentType: "application/json; charset=utf-8", 
     dataType: "json", 

     success: function (msg) { 

      $('#SucessAlert').show(); 
      $("#AddLateStudentAlert").fadeOut(5000); 

     }, 
     error:function() { 
      $('#WarningAlert').show(); 
     } 
    } 
} 
0

error을 사용하십시오. else$.ajax의 유효한 기능이 아닙니다. jQuery의 AJAX docs을 참조하십시오.

예 :

success: function (msg) { 

      $('#SucessAlert').show(); 
      $("#AddLateStudentAlert").fadeOut(5000); 

     }, 
error: function(msg) { 
      $('#WarningAlert').show(); 
} 
0

jQuery.ajax. 사용 오류 콜백에는 else 콜백이 없다

 success: function (msg) { 
      $('#SucessAlert').show(); 
      $("#AddLateStudentAlert").fadeOut(5000); 
     }, 
     error:(jqXHR,textStatus,errorThrown) { 
       console.log(errorThrown) 
      $('#WarningAlert').show(); 
     } 
관련 문제