[英]calling action method from Jquery and redirecting the user to an external site
[英]Redirecting a user to external site from XML response
我正在使用jquery来获取一个php文件,该php文件向外部站点发出php curl请求,并带有付款请求的信息,该外部站点返回如下XML:
<Request valid="1">
<URI>www.dynamicpaymentpage.com/URI>
</Request>
发出请求后,我想找到URI并使用Jquery将客户重定向到该URI。 我能够找到URI并以文本形式或作为警报将其返回,但是无法确定如何重定向页面。 老实说,我对Jquery和PHP经验不足,并且不确定从何而来。 我基本上已经尝试过window.location,但无法正常工作,我不确定从这里去哪里。 有没有人有什么建议?
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({
type: "GET",
url: "deets.php",
success: function(result){
xmlDoc = $.parseXML(result),
$xml = $( xmlDoc ),
$URI = $xml.find( "URI" );
///this is just to make sure I've found the right bit of XML /// $( "#div1" ).append( $URI.text() );
}});
});
});
</script>
</head>
<body>
<div id="div1"></div>
<button>Go!</button>
</body>
</html>
在按钮单击功能的末尾添加它。
window.location.href = "your-url";
希望这可以帮助。
您只需要将URL分配给window.location
例如:
window.location.href = $xml.find("URI").text();
另请参阅https://developer.mozilla.org/zh-CN/docs/Web/API/Window/location
嘿,你可以尝试这样的事情
<page view-id="/view.xhtml">
<action execute="#{facesContext.externalContext.redirect('http://')}" />
</page>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.