이 AJAX 요청은 newsletter-signup.html
파일에 연결 한 다음 반환 된 data
변수에서 "form-success"문자열을 검색합니다. 이 문자열은 if
문 내의 (Django) 템플릿을 통해 적용되어 양식에 성공했음을 알립니다. 이 데이터를 검색 할 수있는 빠른 방법이 있나요Javascript/jQuery :이 AJAX 요청을 더 빨리 실행할 수 있습니까?
if (data.indexOf('form-success') > 0) {
: 여기
전체 데이터를 검색하는 조각이다? 또는 반환 된 데이터가 성공적인 가입인지 여부를 결정하는 더 좋은 방법 인 althoteger일까요?
미리 도움을 주셔서 감사합니다.
$.ajax({ url: '/newsletter-signup', type: 'GET', data: {email: emailVal}, async: false,
success: function(data){
// Returning 'form-success' in our data string indicates the sign up worked
if (data.indexOf('form-success') > 0) {
// open the success message in a modal window
happyModal.open({ content: thankYouContent });
} else {
// if not successful re-load the contents, firing our standard error message
theBtn.removeClass('disabled');
$('.login-panel').load('/newsletter-signup','email=' + encodeURIComponent(emailVal), function() {
});
}
}
});
요청이 진행되는 동안 작은 로딩 그래픽을 보여줍니다. 나는 UI에서 더 빠르게 만들 수있는 일이 있는지 의심 스럽다. –