简体   繁体   English

Ajax请求后的Javascript的window.open函数避免任何弹出窗口阻止程序

[英]Javascript's window.open function after an ajax request avoiding any popup blockers

To sum it up, I collect address info, and the method of payment the user chooses, then via Ajax validate the info with PHP and if the validation fails either show the errors or will redirect the user in a new widow to PayPal. 综上所述,我收集了地址信息以及用户选择的付款方式,然后通过Ajax使用PHP验证信息,如果验证失败,则显示错误或将新寡妇中的用户重定向到PayPal。 I know that window.open must be within an on click so that is the issue. 我知道window.open必须在单击内,这就是问题所在。 I tried having the whole Ajax stuff in a function and calling the function then the redirect all within a large on click but it hasn't worked.Any ideas? 我尝试将整个Ajax内容包含在一个函数中,然后调用该函数,然后在很大的点击范围内全部重定向,但是它没有用。

<- UPDATE -> <-更新->

Not great but it was solved by adding a new step, opening a nifty modal with a prompt and success message. 效果不是很好,但是通过增加一个新步骤解决了该问题,并通过提示和成功消息打开了一个漂亮的模式。

you will probably need two steps in your ui, the first click validates the data via ajax, and then a button appears on success that says something like "success! open paypal". 您可能需要在用户界面中执行两个步骤,首先单击以通过ajax验证数据,然后在成功时显示一个按钮,显示“成功!打开贝宝”之类的内容。 It's a kludgy UX but it will be solid in terms of implementation. 这是一个笨拙的UX,但是在实现方面会很扎实。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM