2012-08-24 3 views
1

컨트롤러에 값 2 개를 게시하는 데 아약스를 사용하고 있는데 컨트롤러에 값이 있지만보기가 표시되지 않습니다. 제가 여기서 잘못하고있는 일을 도와주세요. 감사.MVC + 컨트롤러보기가 표시되지 않습니다.

자바 스크립트 :

function grantPermission() { 
     window.FB.login(function (response) { 
      if (response.authResponse) { 
       uid = response.authResponse.userID; 
       accesstoken = response.authResponse.accessToken; 
       var postData = { facebookUID: uid, facebookAccessTok: accesstoken }; 
       $.ajax({ 
        url: '@Url.Action("SavePhoto")', 
        data: postData, 
        dataType: 'json', 
        success: function (response) { 
         // process the results from the controller action 
         // window.location.href = response.Url; 
        } 
       }); 
      } else { 
       console.log('User cancelled login or did not fully authorize.'); 
       alert('User cancelled login'); 
      } 
     }, { scope: 'publish_stream' }); 
    }; 

버튼 :

<input type="button" id="auth-loginlink" value="Proceed" onclick="grantPermission();"/> 

컨트롤러 : 당신은 뭔가 재치를 할 필요가

public PartialViewResult SavePhoto(string facebookUID, string facebookAccessTok) 
     { 
      return PartialView("BlurredPhoto"); 
     } 
+0

'응답'데이터 란 무엇입니까? 당신은 그것으로부터'Url'을 얻으려고하고 있습니까? –

답변

1

반환 된 HTML을 문서의 어딘가에 다시 넣어야합니다. 예 : 당신이

<div id='MyDiv'> 

를 추가하는 경우 Slaks 언급했듯이 다음

  success: function (responseText, textStatus, XMLHttpRequest) { 
       $("#MyDiv").html(responseText); 
      } 

에 아약스 전화를 변경, 당신은 또한 당신의 return datatype accepts to 'html'을 변경해야합니다.

+1

감사합니다.이게 도움이됩니다! – k80sg

1

h success 콜백에서 서버의 HTML 소스.

jQuery에 HTML이 datatype: 'json'임을 알리는 것으로 시작해야합니다.

관련 문제