简体   繁体   English

通过在窗体onload上提交表单来重定向到新页面

[英]Redirecting to new page by having form submit on body onload

I am doing an ajax call to a 3rd party web service which returns a complete HTML set in one of the field which comes as a response. 我正在对第3方Web服务进行Ajax调用,该服务返回作为响应而在其中一个字段中返回的完整HTML集。 The returned HTML has a logic where in onload event of body it will submit a form to their servlet. 返回的HTML具有逻辑,其中在body的onload事件中,它将向其Servlet提交表单。

This is my web service response : 这是我的网络服务响应:

<rewardresponse>
  <redirectHTML>
   <html>
   <head></head>
   <body onload="document.forms.ssoForm.submit();">
     <form id="ssoForm" action="www.thirdparty.com/SSO/SingleSignOnServlet">
       <input type="hidden" name="customerID" value="1202020"/>
     </form>
   </body>
   </html>
  </redirectHTML>
</rewardresponse>

This is my ajax call : 这是我的ajax电话:

       $.ajax({
          url     : '/rewards/sso',
          type    : 'GET',
          dataType:'json',
          success : function(response){
                  //document.write(response.redirectHTML);
                  document.documentElement.innerHTML = response.redirectHTML;
          }
       })

I have tried document.write and innerHTML thing, both are not working. 我试过document.write和innerHTML的东西,都不能正常工作。 It is changing the html content but redirect is not happening. 它正在更改html内容,但未发生重定向。

Please suggest. 请提出建议。

Instead of making an ajax request, load the /rewards/sso call into an iframe. 无需发出ajax请求,而是将/ rewards / sso调用加载到iframe中。 When it returns html, it will trigger the body onload 返回html时,将触发主体onload

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

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