awesto / django-shop

A Django based shop system
http://www.django-shop.org
BSD 3-Clause "New" or "Revised" License
3.2k stars 1.03k forks source link

Post redirect with AngularJS #745

Closed dismine closed 6 years ago

dismine commented 6 years ago

Hi, Probably this is not appropriate place for this question. But i have tried to find answer myself without luck. How can i submit POST data with AngularJS and get redirect as with usual form? Here is my code.

$http({{ method: '{method}', url: '{url}', data: {{ data: '{data}', signature: '{signature}' }}, headers: {{'Content-Type': 'application/json'}}, }}).then(function successCallback(r) {{ console.log(r);
}},function errorCallback(r) {{ console.error(r); }})

In response callback i get page content instead of link to where i need to redirect. I know that i can achieve redirect with 'window.location.href=', but i need a url.

And yes, i am trying to create a Payment Provider.

dismine commented 6 years ago

According to this answer on Stackoverflow redirect happens long before Angular can do anything about it, and it can't be stopped.

So, instead i send POST data to server each time i need to get redirect url for user. And Angular perform only redirect to correct url.