0

I have the following JS code:

  var data = jQuery.parseJSON('{"name":"John"}');
  $('#name').live("change", function() {
    name = data[$(this).val()];
    alert(name);
  });

It works fine in FireFox, but in IE7 I get the follow JS error:

 Object doesn't support this property or method.
4
  • 1
    .live() is deprecated, use .on() Commented Sep 4, 2012 at 12:56
  • Who is obj[$(this).val()] ? Commented Sep 4, 2012 at 12:57
  • @SnakeEyes Sorry my bad, it should be data[$(this).val()]; Commented Sep 4, 2012 at 13:00
  • on which line you get the error .. Commented Sep 4, 2012 at 13:04

2 Answers 2

1

Do you declareted the name?

var name = ob...

The IE needs to declarate js variables.

Sign up to request clarification or add additional context in comments.

Comments

0

Your question is incomplate.

      var data = jQuery.parseJSON('{"name":"John"}');  
     $('#name').live("change", function() {
         name = obj[$(this).val()];
         alert(name);   });

what is obj?

where you got the error (means which line)

I think any object is returning null values or the functions of js, are not defined

1 Comment

I'm sorry it was a typo, it should be data[$(this).val()];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.