Bili
Bili

Reputation: 21

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.

How can I fix this?

p.s

the function getHidden() wil return a selected item id, it works very fine. I can see that this work!

I put alert() in this function... like this:

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! but not html, so this function stops by function(html), thus by the response! I put try catch in this function, get error: TypeError object doesn't support this property or method

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...

Upvotes: 1

Views: 192

Answers (3)

Bili
Bili

Reputation: 21

solved! I put the script bottom of html file, it works now both FF and IE.

Upvotes: 1

Detect
Detect

Reputation: 2069

Try putting getHidden in a var first.

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

Upvotes: 0

Mahesh Velaga
Mahesh Velaga

Reputation: 21991

What is "result" element ? It probably doesn't support .html() property, try .text() or .val()

Upvotes: 0

Related Questions