Reputation: 5199
I am using jquery in my web application and working with an iframe to show an application hosted on the same websphere server. Through the following code I am able to achieve an automatic login into the web application showing in the iframe....
JSP
<form:form id="posManagerLoginForm"
action="${posManagerUrl}"
target="posManagerFrame"
method="post"
class="ym-form whitenopadding">
<input type="hidden" name="user_name" value="myusername" />
<input type="hidden" name="password" value="mypassword" />
</form:form>
<div class="ym-gbox">
<iframe id="posManagerFrame" name="posManagerFrame" class="posManagerFrame"></iframe>
</div>
JS
$().ready(function() {
$("#posManagerLoginForm").submit();
});
So far so good but now I am now trying to change the JS to be able to get the content in the iframe after the login has happened i.e. after form submit.
$().ready(function() {
$("#posManagerLoginForm").submit(function(e){
e.preventDefault();
this.submit();
var iframe = $("#posManagerFrame").contents();
return true;
});
$("#posManagerLoginForm").trigger("submit");
});
As you can see I register a function for form submit and try and trigger the function on load. I have two issues....
Does anyone know where I am going wrong?
I have posted a couple of questions already this morning. Sorry about that. Thanks for your help.
Upvotes: 0
Views: 10694
Reputation: 1547
This is forbidden due to cross domain origin. You can only get content of iframe from the same domain you are on.
Upvotes: 2