2014-03-31 2 views
1

#pageToLoad이라는 div가 있습니다. formPage.php 페이지는 해당 div에 양식을로드합니다. 해당 페이지가 div에 완전히로드되어 있는지 여부를 알아야합니다. 그래서 모든 종류의 오류가 발생하면 양식을 사용하여 다시 설정할 수 있습니다;div가 완전히 아약스를로드했는지 확인하십시오.

$("#form").reset(); 

어떻게 이벤트를 만들 수 있습니까?

$("#pageToLoad").load("formPage.php"); 

답변

0

당신은 $.ajax(complete:function(responseText, textStatus, XMLHttpRequest)){});에 등록하고 textStatus 값을 확인해야합니다. 확인을 경우, 다음 대상 $('selector') 자신

$.get("formPage.php").success(
    function(response, status, jqXhr){ 
     alert("Success!"); 
    }).error(function (response, status, jqXhr){ 
     alert("These is error."); 
    }).complete(function (response, status, jqXhr){ 
     alert("Complete!"); 
    }); 

또는

$("#pageToLoad").load("formPage.php", function(response, status, xhr) { 
if (status == "error") { 
var msg = "Sorry but there was an error: "; 
$("#error").html(msg + xhr.status + " " + xhr.statusText); 
} 
}); 
0
$("#pageToLoad").load("formPage.php", function(response, status, xhr) { 

if (status == "error") { 
    // "Sorry but there was an error: "; 

} 
else{ 
     $("#form").reset(); 
} 
}); 
로 데이터를로드
관련 문제