www.webdeveloper.com
Results 1 to 5 of 5

Thread: Object doesn't support property or method

  1. #1
    Join Date
    May 2012
    Posts
    3

    Object doesn't support property or method

    I have some forms where a javascript function will only fire 1 time, then I get the 'object doesn't support property or method' error.

    <a onclick="myAccount();" href="#">my account</a>

    It will fire the first click - opens a form - but after closing the form the function does not fire a 2nd time. It happens in both IE & FF. In IE I get this snippet:

    function onclick(event)
    {
    myAccount();return false;
    }

    The funny thing is both Firebug & IE debugger can see and execute the function. From IE debugger:
    function myAccount() {
    retData = $.ajax({
    url: '/administrate/ajax/myAccount/users',
    async: false
    });
    try{
    obj = eval('('+retData.responseText+')');
    if (obj.status == "true") showAltPopup(obj.html);
    if (obj.messages) showError(obj.messages);
    if (obj.code ) eval(obj.code);
    }catch(err) {
    showError(err.message);
    }
    }

    This is my first jquery project [usually use mootools] but not sure if it's related at all.

    Since both IE & FF have problems I assume it's something legitimate, but both of the debuggers can execute it fine.

  2. #2
    Join Date
    May 2012
    Posts
    3

    Additional info

    I encountered this before and a fix like this worked

    function myAccount() {
    }

    to:

    var myAccount = function() {
    }
    worked in some circumstances, but not here.

  3. #3
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    did you try it this way?

    Code:
    function myAccount(){
     retData = $.ajax({
     url: '/administrate/ajax/myAccount/users',
     async: false
     }).responseText;
     try{
     obj = eval('('+retData+')');
     if (obj.status == "true") showAltPopup(obj.html);
     if (obj.messages) showError(obj.messages);
     if (obj.code ) eval(obj.code);
     }
     catch(err){showError(err.message);}
    }
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  4. #4
    Join Date
    May 2012
    Posts
    3
    Same thing. Both as var = myAccount() and function myAccount().

    Works 1st time only.

  5. #5
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    it's hard to deal with a piece of code i surrender
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles