简体   繁体   English

IE的jQuery问题

[英]JQuery issue by IE

I get an error by following code: 我通过以下代码得到一个错误:

jQuery.post('/user/result/generate',{
            'id': getHidden()
        }, function(html) {
            $('#result').html(html);
        });

error: 错误:

TypeError object doesn't support this property or method

this code works fine in FireFox, but not in IE. 此代码在FireFox中可以正常工作,但在IE中则不能。

How can I fix this? 我怎样才能解决这个问题?

ps ps

the function getHidden() wil return a selected item id, it works very fine. 函数getHidden()将返回选定的项目ID,它工作得很好。 I can see that this work! 我可以看到这项工作!

I put alert() in this function... like this: 我在这个函数中添加了alert(),就像这样:

jQuery.post('/user/result/generate',{
        'id': getHidden()
    }, function(html) {
        alert(html);
        $('#result').html(html);
    });

function getHidden(){
alert($("#selectId").val());
return $("#selectId").val();

} }

and I get the selectId well! 我的selectId很好! but not html, so this function stops by function(html), thus by the response! 但不是html,因此此函数由function(html)停止,因此由响应停止! I put try catch in this function, get error: TypeError object doesn't support this property or method 我在该函数中放入try catch,得到错误:TypeError对象不支持此属性或方法

but this function works fine after refresh the page by press F5.... so I do not understand why this function works not directly but after refresh... 但是此功能在按F5刷新页面后可以正常工作。...所以我不明白为什么此功能不能直接工作而是在刷新后工作...

solved! 解决了! I put the script bottom of html file, it works now both FF and IE. 我将脚本放在html文件的底部,现在可以同时使用FF和IE了。

What is "result" element ? 什么是“结果”元素? It probably doesn't support .html() property, try . 它可能不支持.html()属性,请尝试。 text() or .val() text().val()

Try putting getHidden in a var first. 尝试先将getHidden放入var中。

var getId = getHidden();
jQuery.post('/user/result/generate',{
            'id': getId
        }, function(html) {
            $('#result').html(html);
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM