java - send post request to login from client website to sevice provider web -
client website(asp.net) has icons on onclick event triggered. provider website(java) onclick,
function gotourl(){ window.open(url) } url this: https://example.org/j_spring_security_check?name=testing&pass=testing'
issue is, in spring 3 login submission doesn't allow requests(i think)..
used following javascript post csrf token issues comes up.
function openwindowwithpost(url,name,keys,values) { var newwindow = window.open(url, name); if (!newwindow) return false; var html = ""; html += "<html><head></head><body><form id='formid' method='post' action='" + url + "'>"; if (keys && values && (keys.length == values.length)) (var i=0; < keys.length; i++) html += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>"; html += "</form><script type='text/javascript'>document.getelementbyid(\"formid\").submit()</script></body></html>"; newwindow.document.write(html); return newwindow; } any suggestions on how resolve this..
well should not setting url in new window in open.
var newwindow = window.open(url, name); should be
var newwindow = window.open('', name); you avoid whole pop using form on page action , target set
<form action="https://example.org/j_spring_security_check" method="post" target="_blank"> <input type="hidden" name="foo" value="bar" /> </form>
Comments
Post a Comment