I'm trying to make a cross domain POST using the following jQuery popup. IE gives me permission denied on Line 19 of jquery.min.js. Please note that I have the following script running on www.mysite.com and I'm trying to post the data to www.google.com for example. Thus making a cross domain post. I assume this is why IE is giving me permission denied. I know there should be a solution to create a hidden iframe but I have no idea how to implement this in my code. Some examples would be greatly appreciated. Thanks in advance!
<html>
<head>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/smoothness/jquery-ui.css" type="text/css" />
<style type="text/css">
#register { display: none; }
.ui-dialog { font-size: 10px; }
.ui-dialog .ui-dialog-titlebar-close { visibility: hidden; }
</style>
</head>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script>
<script type="text/javascript">
function loadpopup(){
function Init()
{
jQuery('#register').dialog({ width: 400, resizable: false, buttons: { "Continue": function() {
if (jQuery("#email").val().length < 3)
{
alert('Please enter your email address to continue.');
jQuery("#email").focus();
}
else
{
jQuery("#email_2").val(jQuery("#email").val());
$.post("http://google.com/register.php", $("form[name='registerform']").serialize());
jQuery('#register').dialog('close')}
}
}, closeOnEscape: false, modal: true, show: 'slide' });
}
jQuery(document).ready(Init);
}
loadpopup();
</script>
<div id="register">
<form>
<center>
<table><tbody>
<tr><td align="center" style="text-align: center; font-size: 10px; background: #FFFFFF;">
<br><h3>Register</h3>
</td></tr>
<tr><td align="left" style="text-align: justify; font-size: 11px; background: #FFFFFF;">
Please enter your email address to continue.</br></br>
</td></tr>
</tbody></table></center>
<center>
<div>
<table>
<tbody>
<tr><td align="left" style="font-size: 12px; background: #FFFFFF;"><b>Email:</b></td><td align="left" style="background: #FFFFFF; font-size: 11px;"><input type="text" id="email" name="email" maxlength="26"/></td></tr>
</tbody>
</table>
&l开发者_如何学Pythont;/div>
</form>
</center>
</div>
<form name="registerform" action="http://google.com/register.php" method="post">
<input type="hidden" name="email_2" id="email_2" />
</form>
</body>
</html>
You are posting via XHR to a different domain. You can't do that because of same origin policy.
Instead, build the form and then call submit()
on it.
The way you are doing it now, Google is returning 405 Method Not Allowed
which could be returned for a number of reasons.
精彩评论