asp.net/jQuery:使用jQuery将数据发布到弹出窗口[IE]

asp.net/jQuery:使用jQuery将数据发布到弹出窗口[IE],jquery,asp.net,internet-explorer,post,popup,Jquery,Asp.net,Internet Explorer,Post,Popup,我正在尝试将asp.net应用程序中的jQuery数据发布到弹出窗口 如果弹出窗口打开,我会得到三个错误。 第一个错误是: Errror: the value of the property is null or undefined not a function object (错误代码[代码在弹出站点中]:http://www.suckmypic.net/26449/e65f2d77.png, 原始代码[代码在弹出站点中]:http://www.suckmypic.net/26450/7

我正在尝试将asp.net应用程序中的jQuery数据发布到弹出窗口

如果弹出窗口打开,我会得到三个错误。 第一个错误是:

 Errror: the value of the property is null or undefined not a function object
(错误代码[代码在弹出站点中]:http://www.suckmypic.net/26449/e65f2d77.png, 原始代码[代码在弹出站点中]:http://www.suckmypic.net/26450/7dfdf013.png)

然后我得到了正确包含的私有函数的两个错误

然后-如果我正在重新加载弹出窗口,一切正常。

我以这种方式打开弹出窗口:

$.post('popup.aspx', { X: $("#X1").val(), XX: varX, XXX: varXY, Z: varZ}, function (result) {

  hWndHelp = window.open('', 'help', cStyle);
  hWndHelp.focus();
  hWndHelp.document.open();
  hWndHelp.document.write(result);
  hWndHelp.document.close();
});
(它存储在我按f1键调用的函数中,该函数工作正常)

我在主页和弹出窗口中引用我的所有函数和jquery库

编辑

cStyle
var的代码:

var WIN_STYLE_RESIZE =
    'resizable = yes, ' +
    'status = yes, ' +
    'scrollbars = yes';

var cStyle =
        WIN_STYLE_RESIZE + ', ' +
        'width = ' + w + ', ' +
        'height = ' + h + ', ' +
        'top = ' + y + ', ' +
        'left = ' + x;
(w、h、y、x是根据窗口大小计算的数字)

如果我简单地将其更改为宽度=600,高度=400,错误仍然会发生

如果我通过
get
发送变量,它也可以工作,但我需要在URL中隐藏变量

工作获取方法:

var getUrl = "popup.aspx?X="+$('#X1').val()+"&....";
hWndHelp = window.open(getUrl, 'help', cStyle);
另一编辑:
刚刚尝试了chrome和firefox-没有错误。但是我需要代码来处理IE

在访问
窗口之前,请给我一些时间打开它。试试这个

$.post('popup.aspx', { X: $("#X1").val(), XX: varX, XXX: varXY, Z: varZ}, function (result) {

  var hWndHelp = window.open('', 'help', cStyle);
  setTimeout(function(){
     hWndHelp.focus();
     hWndHelp.document.open();
     hWndHelp.document.write(result);
     hWndHelp.document.close();
  }, 400);
});

看起来您在popup.aspx中缺少jQuery。确保它包含在内。

我想jquery库在这两个页面上都被加载了

您还将$.post包含在$(function(){……}

$.ajax的$.post速记函数,因此它是异步的。 我建议尽可能使其同步。

尝试以下方法:

$.ajax({
  type: 'POST',
  url: 'popup.aspx',
  data: { X: $("#X1").val(), XX: varX, XXX: varXY, Z: varZ},
  success: function(data, textStatus, jqXHR) {

     var hWndHelp = window.open('about:blank', 'help', cStyle);

     hWndHelp.focus();
     hWndHelp.document.open();
     hWndHelp.document.write(data);
     hWndHelp.document.close();

  },
  dataType: 'html'
});

首先感谢您的回复

我已经试过了所有的答案,但我仍然总是在internet explorer中发现错误

我已经找到了一个解决方法,但它并没有让我高兴,因为我认为生成一个带有输入字段的新表单太难满足我的需要了

因为它是将我的数据发布到弹出窗口中而不出现jQuery错误的唯一有效选项,所以我决定使用它

var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "popup.aspx");
form.setAttribute("target", "help");

var input = document.createElement("input");
input.type = "hidden";
input.name = "X";
input.value = $("#X").val();
form.appendChild(input);

var input2 = document.createElement("input");
input2.type = "hidden";
input2.name = "XX";
input2.value = varX;
form.appendChild(input2);

var input3 = document.createElement("input");
input3.type = "hidden";
input3.name = "XXX";
input3.value = varXY;
form.appendChild(input3);

var input4 = document.createElement("input");
input4.type = "hidden";
input4.name = "Z";
input4.value = varZ;
form.appendChild(input4);

document.body.appendChild(form);

hWndHelp = window.open("about:blank", "help", cStyle);
hWndHelp.focus();

form.submit();
document.body.removeChild(form);
原始资料来源:

我制作了一个jQuery插件来实现这一点。不必是jQuery,但我的是

(function ($) {
    $.submitFormToPopup = function (action, params, target, windowOpts) {
        var formID = 'submitFormToPopup';
        var form = $('<form />')
            .attr('method', 'post')
            .attr('action', action)
            .attr('target', target)
            .attr('id', formID);
        $.each(params, function (key, value) {
            form.append($('<input />')
                .attr('type', 'hidden')
                .attr('name', key)
                .attr('value', value));
        });
        $(document.body).append(form);
        window.open('about:blank', target, windowOpts);
        form.submit();
        $(document.body).remove('#' + formID);
    };
})(jQuery);
(函数($){
$.SubmitFormTopoppup=函数(操作、参数、目标、windowOpts){
变量formID='submitFormToPopup';
变量形式=$('')
.attr('method','post')
.attr('action',action)
.attr('target',target)
.attr('id',formID);
$.each(参数、函数(键、值){
表单.附加($('')
.attr('类型','隐藏')
.attr('name',key)
.attr('value',value));
});
$(document.body).append(表单);
window.open('about:blank',target,windowOpts);
表单提交();
$(document.body).remove(“#”+formID);
};
})(jQuery);

在开关行中,您得到了第一个错误?第2行(第1行为空)我找不到您了,您能在代码上指出这一点吗?如果错误在方法中的第一个代码行,则仅引用
窗口(始终可用)和
cStyle
,它不在函数参数中,我必须假设对cStyle变量的引用无效。您可以显示操纵该变量的代码吗?尽管我不确定即使是空cStyle也会做什么,从而导致给出特定的错误消息。您可能希望发布更多的代码,因为我怀疑有些交互很重要,您还没有向我们展示。那么,您会怎么做呢?我尝试过:function myFunction(){
$('#myForm')。submit(function(){window.open('popup.aspx','help',cStyle);$('#myForm')。按F1时提交()}
(如前所述,我正在以这种方式调用我的函数),一个窗口打开,但在下一秒主页将重新加载。