Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.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 Jquery.post在firefox中不工作_Javascript_Jquery - Fatal编程技术网

Javascript Jquery.post在firefox中不工作

Javascript Jquery.post在firefox中不工作,javascript,jquery,Javascript,Jquery,我编写了一个javascript,它使用Jquery.post从web应用程序加载网页。我在iframe中显示页面。该网页在IE中显示,但在firefox中不显示。我尝试使用Firebug,但没有错误,它有一个302OK注释。我尝试更改Jquery源代码,但也没有成功。尝试了同样不起作用的JSON。我试图解决这个问题已经三天多了。我尝试了很多方法,但都没有效果 <html> <head> <script type="text/javascr

我编写了一个javascript,它使用Jquery.post从web应用程序加载网页。我在iframe中显示页面。该网页在IE中显示,但在firefox中不显示。我尝试使用Firebug,但没有错误,它有一个302OK注释。我尝试更改Jquery源代码,但也没有成功。尝试了同样不起作用的JSON。我试图解决这个问题已经三天多了。我尝试了很多方法,但都没有效果

 <html>
  <head>
     <script      type="text/javascript"src="http://ajax.microsoft.com/ajax/jquery/jquery1.4.2.min.js">
     </script>
    <script type="text/javascript">


    function callajax()
    {
       var iframe =document.createElement("iframe");
       iframe.style.width="100%";
       iframe.style.height="100%";
       //app.getContentEl().appendChild(iframe);
       document.body.appendChild(iframe);
       jQuery.post('http://localhost:9090/simpleapp/formproc1',     {'param':'rajat'},function(html){


        var doc =iframe.contentWindow.document;
        doc.write(html);
        doc.close();
        });
        }



        </script>
        </head>

        <body>
         <p>Start typing a name in the input field below:</p>
         <span></span>
         <div id="display"></div>
         First name:

         <input type="text" />

         <button onclick="callajax()">Click me</button>
         </body>
         </html>
//TODO自动生成的方法存根

      PrintWriter out = response.getWriter();

      String par = request.getParameter("param");

       System.out.print("Hiii this is inside POST method");

        //out.println("<data><param>"+par+"</param></data>");

        //out.println(par);

        //out.flush();

        //System.out.print(par);

         response.sendRedirect("first.jsp");

         // out.println("{\"redirect\":\"first.jsp\"}");

         }
PrintWriter out=response.getWriter();
字符串PAR=请求.GETFALSE(“PARAM”);
系统输出打印(“Hiii这是内部POST方法”);
//out.println(“+par+”);
//out.println(par);
//out.flush();
//系统输出打印(par);
sendRedirect(“first.jsp”);
//println(“{\”重定向\“:\”first.jsp \“}”);
}
这是因为。不能使用ajax调用外部站点。如果你真的想用,你必须用。或者,您可以使用服务器端代理进行此操作。也就是说,在服务器端调用外部站点,并对该Web服务进行ajax调用

看我的回答,,

尝试发出警报,并检查在单击按钮后是否调用了该方法。请描述该方法“不起作用”的原因。它是否创建iframe?iframe是否已填充?您是否尝试在firebug中手动调用jQuery.post函数?非常感谢您的快速响应。Firebug没有显示任何错误。但是响应为空。请求成功通过。并且创建了iframe,但没有在iframe中填充网页。你现在能帮我吗谢谢你的回答。但是如果使用JSONP,那么如果POSt方法响应是一个网页,将会发生什么呢。网页是否会显示在iframe中?我的意思是,如果网页可以作为参数传递给回调函数,请解释一下。
      PrintWriter out = response.getWriter();

      String par = request.getParameter("param");

       System.out.print("Hiii this is inside POST method");

        //out.println("<data><param>"+par+"</param></data>");

        //out.println(par);

        //out.flush();

        //System.out.print(par);

         response.sendRedirect("first.jsp");

         // out.println("{\"redirect\":\"first.jsp\"}");

         }