我使用ajax發佈2個值到我的控制器,控制器得到的值,但不會顯示視圖。請幫助我在這裏做錯了。謝謝。MVC +控制器視圖不顯示
的Javascript:
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");
}
什麼是響應數據?你正在試圖從它獲得'Url'? –