0

I post the data to server and receive data from server , In data, It have a url , then I will open the url in new Tab, but when I use $window.open(data.url) to open ,it is not working

I can not found any error in console ,this is my code

$http({
  method  : 'POST',
  url     : url,
  data    : $.param(formData),  // pass in data as strings
  headers : { 'Content-Type': 'application/x-www-form-urlencoded' }  
})
.success(function(data) {
    $window.open(data.url)
});      
1
  • Your browser may prevent to open popup window. Chek the settings. Commented Feb 16, 2016 at 11:12

2 Answers 2

1

Try this : $window.open(data.url, '_blank');

Sign up to request clarification or add additional context in comments.

Comments

0

I had a similar issue, for me it worked when I changed it to redirect, instead of opening a new window/tab:

$window.location.href = data.url;

If this does it, then I would say the issue is that the browser is blocking the popup, as it is not opened via direct input from user.

If not, try logging your data object that is returned from the server to ensure that it has URL correctly set in it, and that you actually enter the function.

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.