5
"getproduct"버튼을 클릭하면 제품을 사용할 수 없으면 ajax 호출이 제품 또는 404 코드를받습니다.성공할 때까지 ajax 호출을 반복하는 방법
제품이 반환 될 때까지 getMyJson이 5 초마다 다시 호출되기를 원합니다.
아이디어가 있으십니까?
$(function() {
$("#getproduct").click(function getMyJson() {
$.ajax({
type: "GET",
url: "Product/GetProduct",
dataType: "json",
success: function (data) {
//alert("succes");
$("#name").html(data.Name);
$("#price").html(data.Price);
},
error: function() {
//alert("fail");
//callback getMyJson here in 5 seconds
}
});
});
});
error
콜백 함수에setTimeout
을 사용할 수 있습니다. 많은 감사 :-) – Maxime