1
var app = angular.module("myApp",[]);
app.controller("myCtrl",function($scope,$http){

$http({
                method: 'POST',
                url: '../api/CreateOrder',
                data: Object.toparams(myobject),
                headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
            }).then(function successCallback(response) {

                window.location.href = "checkout.html?OrderId=" + response.data;


            }, function errorCallback(response) {

                alert("Error. while updating user Try Again!");

            });

});

Here is my code , I am receiving response from http GET , How to transfer the response data which has OrderId to window.location.href as Parameter?

4
  • can you post an example of response.data? Commented Feb 5, 2020 at 12:18
  • In repsonse I get an array [{OrderId : 25 }] Commented Feb 5, 2020 at 12:37
  • You'll have to access the property OrderId within your response.data. If what you say is correct, it should be response.data[0].OrderId This takes the first object from the responsedata array. You should ofcourse check if there is any item in the response.data. Commented Feb 5, 2020 at 12:46
  • I tried that but getting URL Like this : localhost:56861/public/checkout.html?OrderId=[object%20Object] If i pass response.data in window.location.href = "checkout.html?OrderId ="+response.data Commented Feb 6, 2020 at 6:38

2 Answers 2

2

Let's assume that response.data is [{OrderId : 25 }] then try

window.location.href = "checkout.html?OrderId=" + response.data[0].OrderId;
Sign up to request clarification or add additional context in comments.

1 Comment

I tried that but getting URL Like this : localhost:56861/public/checkout.html?OrderId=[object%20Object] If i pass response.data in window.location.href = "checkout.html?OrderId ="+response.data –
0
search(search, [paramValue]);

This method is getter / setter.

Return search part (as object) of current URL when called without any parameter.

Change search part when called with parameter and return $location.

$location.search({OrderId : 25 });

locationSearchStatus = $location.search();

AngularJs Doc

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.