사용자가 드롭 다운 목록 중 하나에서 값을 변경하면 양식의 일부 컨트롤을 변경해야하는 양식이 있습니다. 현재 설정되어있는 방식 ...
success
AJAX 호출 의 기능에서location.reload()
현재 문제는 자동 저장 방법이 완료되기 전에 때때로 다시로드가 발생한다는 것입니다. 자동 저장이 완전히 완료 될 때까지만 페이지를 새로 고침하려면 어떻게해야합니까? 내가 설정하지 않으 async: false
에서 $.ajax
이 대기를 기쁘게을 말하는 표시되는 사용자에게 내 메시지 전에 전체 페이지를 동결하기 때문이다. 아래에 포함 할 코드를 잊은 경우 알려주세요. 감사합니다!
reports.coffee
autoSavePost = (reload) ->
console.log('autosave executed');
$.ajax
type: 'PUT'
url: '/reports/autosave'
data: $('#report-form').serialize()
dataType: 'script'
success: (data) ->
if reload
setTimeout(location.reload(), 5000);
return true
error: (xhr, ajaxOptions, thrownError) ->
console.log xhr.responseText.substr(0,1500)
return false
# schedule the next autosave
if $('#auto-save').length
setTimeout autoSavePost, 60000
else
return false
return
$ ->
$(document).on 'change', '#report_position_id', (evt) ->
$.blockUI({ message: '<h5>Please wait, "Position Graded" is being changed...</h5>' });
# grey out screen with message until page reloads.
autoSavePost(true)
return
컨트롤러 함수에서 js를 렌더링하고 렌더링되는 js 파일은 window.reload를 호출합니다.
또는 render head : ok는 ajax 성공을 트리거 한 다음 window.reload
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다