Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在window.open()中执行POST_Javascript_Jquery_Http Post - Fatal编程技术网

Javascript 在window.open()中执行POST

Javascript 在window.open()中执行POST,javascript,jquery,http-post,Javascript,Jquery,Http Post,我试图打开一个弹出窗口,我想在它打开时使用post方法发送数据。 有人能帮我吗 我收到“未捕获语法错误。意外标记}” 函数MapIt(){ var ListIds=selected_Listings.join(); 如果(navigator.appName==“Microsoft Internet Explorer”){ var opts=“screenX=0,screenY=0,width=“+screen.width+”,height=“+screen.height; }否则{ var op

我试图打开一个弹出窗口,我想在它打开时使用post方法发送数据。 有人能帮我吗

我收到
“未捕获语法错误。意外标记}”

函数MapIt(){
var ListIds=selected_Listings.join();
如果(navigator.appName==“Microsoft Internet Explorer”){
var opts=“screenX=0,screenY=0,width=“+screen.width+”,height=“+screen.height;
}否则{
var opts=“outerWidth=“+screen.availWidth+”,outerHeight=“+screen.availHeight+”,screenX=0,screenY=0”;
}    
var urlStr=”http://www.dev.theabc.com/bingmaps/Map  ";     
$('').submit();
}

实际上。。。表单中的语法错误 应该是这样的

$('<form action="'+urlStr+' target="submission" onsubmit="window.open(\'http://www.google.com\',\'Map\',\''+opts+',toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no\');return true;" method="post"><input type="hidden" value="'+ListIds+'"></form>').submit();

$('在知道你并不真正想要一篇文章之后

<html>
 <head>
   <script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script>
   <script type='text/javascript'>
   $(function(){
     MapIt = function() {
       ListIds = '1234';//selected_Listings.join();
       if (navigator.appName == "Microsoft Internet Explorer") {
         var opts = "screenX=0,screenY=0,width=" + screen.width + ",height=" + screen.height;
       } else {
         var opts = "outerWidth=" + screen.availWidth + ",outerHeight=" + screen.availHeight + ",screenX=0,screenY=0";
       }
       $('#myHidden').val(ListIds);
       window.open('opener.html','Map', opts+',toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no');

     }
    });
   </script>
 </head>
 <body>
  <button id="run" onclick="MapIt()">run</button>
  <input type="hidden" id="myHidden">
 </body>
</html>

$(函数(){
MapIt=函数(){
ListIds='1234';//选定的_清单。join();
如果(navigator.appName==“Microsoft Internet Explorer”){
var opts=“screenX=0,screenY=0,width=“+screen.width+”,height=“+screen.height;
}否则{
var opts=“outerWidth=“+screen.availWidth+”,outerHeight=“+screen.availHeight+”,screenX=0,screenY=0”;
}
$('#myHidden').val(ListIds);
open('opener.html','Map',opts+',toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizeable=no');
}
});
跑
然后在opener.html中添加一个

<html>
 <head>
   <script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script>
   <script type='text/javascript'>
     $(function(){
        var listIds = window.opener.document.getElementById('myHidden').value;
    $('#valuesRead').text(listIds);
      });
   </script>
 </head>
 <body>
   <span id="valuesRead"></span>
 </body>
</html>

$(函数(){
var listIds=window.opener.document.getElementById('myHidden').value;
$('#valuesRead').text(listIds);
});

当心这在某些浏览器中存在()安全问题,如果您在本地运行它

这可能会导致问题,
onsubmit=“window.open(”“,
我不清楚你在说什么。请举个例子。编辑答案并在IE、Chrome和Firefox上测试。谢谢。我不得不删除操作,因为这会导致在父页面上回发。现在表单标记看起来像:$('').submit();---但问题是帖子没有发生。(我想发布listid)事实上,它应该..但获取帖子的是操作中的url()…window.open中的url可以读取其父窗口(window.opener)的元素…因此在页面中它可以像window.opener.forms[0]一样读取它.HiddenElementId…但在此示例中,您的隐藏元素必须有一个Id,它丢失了…因为您不想回发…为什么还要使用表单?您可以只使用一个按钮来创建window.open…并在该打开的窗口中读取输入元素form window.opener…window.opener.getElementById('theID')).不重视名字和身份证!在我花了这么多时间解决你的问题之后…你会接受它作为答案吗?谢谢@pimboden。我真的很感谢你的帮助。
<html>
 <head>
   <script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script>
   <script type='text/javascript'>
   $(function(){
     MapIt = function() {
       ListIds = '1234';//selected_Listings.join();
       if (navigator.appName == "Microsoft Internet Explorer") {
         var opts = "screenX=0,screenY=0,width=" + screen.width + ",height=" + screen.height;
       } else {
         var opts = "outerWidth=" + screen.availWidth + ",outerHeight=" + screen.availHeight + ",screenX=0,screenY=0";
       }
       $('#myHidden').val(ListIds);
       window.open('opener.html','Map', opts+',toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no');

     }
    });
   </script>
 </head>
 <body>
  <button id="run" onclick="MapIt()">run</button>
  <input type="hidden" id="myHidden">
 </body>
</html>
<html>
 <head>
   <script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script>
   <script type='text/javascript'>
     $(function(){
        var listIds = window.opener.document.getElementById('myHidden').value;
    $('#valuesRead').text(listIds);
      });
   </script>
 </head>
 <body>
   <span id="valuesRead"></span>
 </body>
</html>