Im trying to retrieve a token from an url that must be redirected from my method. It works in a different method but doesn't work in this one. Any help would be appreciated!
Controller method:
[HttpPost]
public ActionResult Authorize(int clientId)
{
Session["client_Id"] = clientId;
var client = GoogleAnalyticsHelper.CreateGoogleAnalyticsClient();
string url = client.AuthorizeUrl();
return Redirect(url);
}
JavaScript:
function UpdateClient() {
var baseurl = "/GoogleAnalytics/";
var list = document.getElementById("clientId");
var clientId = list.options[list.selectedIndex].value;
$.ajax({
type: "POST",
async: false,
url: baseurl + "Authorize",
data: { "clientId": clientId },
success: function () {
console.log("success!");
},
error: function (er) {
console.log("an error occured: " + er);
}
});
};
Button:
<button type="submit" onclick="UpdateClient()" name="button1" class="btn btn-info">Update client/ViewId</button>
Ive found a solution and the problem was with Google Chrome. My solution in the success:
success: function (url) {
setTimeout(function () {
window.location.assign(url);
}, 0);
},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.