2

How can i mimic the traditional way of posting data in AngularJS, where the URL is loaded with the paramters sent. Here is my Controller below :

 $scope.CallWebPay = function(){
  console.log($scope.pay);

  $scope.pay.hash = CryptoJS.SHA512($scope.pay);
  var paramObj = {
    product_id : $scope.pay.product_id,
    pay_item_id : $scope.pay.pay_item_id,
    amount : $scope.pay.amount,
    currency : $scope.pay.currency,
    site_redirect_url : $scope.pay.site_redirect_url,
    txn_ref : $scope.pay.txn_ref,
    cust_id : $scope.pay.cust_id,
    hash : $scope.pay.hash
};

  $http.post('https://www.testpayment.com/test_paydirect/pay', paramObj ).
    then(function(response) {

    }, function(response) {



    });

}

Expect Behaivour Making a POST Request to that link should cause the page at the endpoint to redirect to another page, but right now nothing is happening.

kolexinfos
  • 1,030
  • 1
  • 21
  • 42
  • http://stackoverflow.com/questions/12190166/angularjs-any-way-for-http-post-to-send-request-parameters-instead-of-json ? – Sergiu Paraschiv Sep 07 '15 at 13:35
  • this passes the parameters as form data but does not do the redirect to the URL provided – kolexinfos Sep 07 '15 at 13:39
  • There is no HTTP or AngularJS built-in mechanism that would do that redirect. That's something the script you are POSTing to has to do. – Sergiu Paraschiv Sep 07 '15 at 13:43
  • There might be a redirection caused by HTML or JS in the response. These get handled by browser if opened as a web page, but not effective in AJAX, since the response is not parsed. You can use developer tools to check if this is the case. – FelisCatus Sep 07 '15 at 14:35
  • Please explain expected behavior in more detail. Perhaps you don't even need ajax but details are not clear – charlietfl Sep 07 '15 at 15:10

0 Answers0