2011-08-24 4 views
0

현재 페이지를 리디렉션하려면 ajax() 함수 내에서 window.document.location() 문을 사용합니다. 하지만 오류가 발생했습니다 (방화 밧데리). 기능 요청에 오류가 없으며 응답이 제대로 전달됩니다. window.document.location('user/index.php'); 문이 문제를 만듭니다. msg=='YES'의 경우이 페이지를 다른 페이지로 리디렉션 할 수 있습니까?jquery ajax() 메서드에서 오류가 발생 했습니까?

$.ajax({ 
      url: "user_registration.php", 
      type: "post", 
      data: datastring, 
      success: function(msg) { 
       if(msg=='YES') {         
        window.document.location('user/index.php'); 
       } 
       else 
        $("#success").html(msg); 
     } 
    }); 
+0

체크 아웃? –

답변

1

성공 처리기에서 window.location = newLocation;라고 말하면 새 위치로 리디렉션됩니다. window.locationhere

$.ajax ({ 
    url: "user_registration.php", 
    type: "post", 
    data: datastring, 
    success: function(msg) { 
      if(msg=='YES') {         
       window.location = 'user/index.php'; 
      } 
      else { 
      $("#success").html(msg); 
      } 
    } 
}); 

더.

0

상대 URL이 "/user/index.php"여야합니까? 잊지 마세요

+0

그러면 절대 (현재 도메인 이름에서 시작) – Veger

+0

오 예! 내 실수! 감사합니다 =) –

0
window.location.href = 'user/index.php'; 

은, YES하지 예

0

사용 window.location.replace("http://www.w3schools.com") 작업을해야하는, YES해야합니다.

자세한 내용은 '/ index.php를 사용자 = document.location.href 의미하지 마십시오 w3schools page on this topic

관련 문제