我正在使用 ajax 将 2 个值发布到我的控制器,控制器得到了值但不会显示视图。请协助我在这里做错了什么。谢谢。
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");
}